当前位置: 首页>>代码示例>>C#>>正文


C# Point.GetType方法代码示例

本文整理汇总了C#中Point.GetType方法的典型用法代码示例。如果您正苦于以下问题:C# Point.GetType方法的具体用法?C# Point.GetType怎么用?C# Point.GetType使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Point的用法示例。


在下文中一共展示了Point.GetType方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: Main3

 public static void Main3()
 {
     // Create two Point instances on the stack. 
     Point p1 = new Point(10, 10);
     Point p2 = new Point(20, 20);
     // p1 does NOT get boxed to call ToString (a virtual method). 
     Console.WriteLine(p1.ToString());// "(10, 10)" 
     // p DOES get boxed to call GetType (a non-virtual method). 
     Console.WriteLine(p1.GetType());// "Point" 
     // p1 does NOT get boxed to call CompareTo. 
     // p2 does NOT get boxed because CompareTo(Point) is called. 
     Console.WriteLine(p1.CompareTo(p2));// "-1" 
     // p1 DOES get boxed, and the reference is placed in c. 
     IComparable c = p1;
     Console.WriteLine(c.GetType());// "Point" 
     // p1 does NOT get boxed to call CompareTo. 
     // Since CompareTo is not being passed a Point variable, 
     // CompareTo(Object) is called which requires a reference to 
     // a boxed Point. 
     // c does NOT get boxed because it already refers to a boxed Point. 
     Console.WriteLine(p1.CompareTo(c));// "0" 
     // c does NOT get boxed because it already refers to a boxed Point. 
     // p2 does get boxed because CompareTo(Object) is called. 
     Console.WriteLine(c.CompareTo(p2));// "-1" 
     // c is unboxed, and fields are copied into p2. 
     p2 = (Point)c;
     // Proves that the fields got copied into p2. 
     Console.WriteLine(p2.ToString());// "(10, 10)" 
 }
开发者ID:eric7237cire,项目名称:CodeJam,代码行数:29,代码来源:Boxing1.cs

示例2: Main

 public static void Main()
 {
     Point p = new Point(7, 3);
     p.Print();
     Console.WriteLine(p.ToString()); // Redefinido em Point
     Console.WriteLine(p.GetType()); // box + call
     Console.WriteLine(p.GetHashCode()); // Herdado de Object
 }
开发者ID:Kadete,项目名称:ave-2013-14-sem2,代码行数:8,代码来源:PointApp.cs

示例3: Main

    static void Main()
    {
        A a = new A();
        Point p = new Point(7, 11);

        Type typeOfA = a.GetType();
        Type typeOfPoint = p.GetType();
    }
开发者ID:isel-leic-ave,项目名称:ave-2015-16-sem1-i41n,代码行数:8,代码来源:App03-value-types.cs

示例4: PointShouldBeValidWithCorrectValues

		public void PointShouldBeValidWithCorrectValues()
		{
			var newPoint = new Point(10, 10, 102100);

			newPoint.Should().Not.Be.Null();
			newPoint.GetType().Should().Be<Point>();
			newPoint.X.Should().Be(10);
			newPoint.Y.Should().Be(10);
			newPoint.SpatialReference.WKID.Should().Be(102100);
		}
开发者ID:nodfreitas,项目名称:ArcGISRestToolkit.NET,代码行数:10,代码来源:PointTest.cs

示例5: Page_Load

    protected void Page_Load(object sender, EventArgs e)
    {
        Point p = new Point(100, 200);
        JavaScriptSerializer jss = new JavaScriptSerializer();
        string json = jss.Serialize(p);
        JsonOutput.Text = HttpUtility.HtmlEncode (json);

        MemoryStream ms = new MemoryStream();
        XmlSerializer xs = new XmlSerializer(p.GetType());
        xs.Serialize(ms, p);
        string xml = new ASCIIEncoding().GetString(ms.ToArray());
        XmlOutput.Text = HttpUtility.HtmlEncode (xml);
    }
开发者ID:trasa,项目名称:presentations,代码行数:13,代码来源:Json.aspx.cs

示例6: ClickablePointPropertyTest

		public virtual void ClickablePointPropertyTest ()
		{
			IRawElementProviderSimple provider = GetProvider ();

			bool offscreen 
				= (bool) provider.GetPropertyValue (AutomationElementIdentifiers.IsOffscreenProperty.Id);
			object clickablePointObj 
				= provider.GetPropertyValue (AutomationElementIdentifiers.ClickablePointProperty.Id);

			Point clickablePoint = new Point (0, 0);

			// Clickable point should be either null or Rect.Empty
			if (offscreen) {
				if (clickablePointObj != null) {
					try {
						clickablePoint = (Point) clickablePointObj;
						Assert.IsTrue (clickablePoint.X >= 0,
						               string.Format ("X is negative, your provider should be OffScreen: {0}", clickablePoint.X));
						Assert.IsTrue (clickablePoint.Y >= 0,
						               string.Format ("Y is negative, your provider should be OffScreen: {0}", clickablePoint.Y));

					} catch (InvalidCastException) {
						Assert.Fail (string.Format ("You are not returning System.Windows.Point in ClickablePointProperty: {0}",
						                            clickablePoint,GetType ()));
					}
				}
			// Clickable point should intersect bounding rectangle...
			} else {
				if (clickablePointObj == null) // ...unless you are not clickable at all
					return;

				Assert.IsNotNull (clickablePoint, 
				                  "Your ClickablePointProperty should not be null.");

				try {
					clickablePoint = (Point) clickablePointObj;
					Assert.IsTrue (clickablePoint.X >= 0,
					               string.Format ("X is negative, your provider should be OffScreen: {0}", clickablePoint.X));
					Assert.IsTrue (clickablePoint.Y >= 0,
					               string.Format ("Y is negative, your provider should be OffScreen: {0}", clickablePoint.Y));

				} catch (InvalidCastException) {
					Assert.Fail (string.Format ("You are not returning System.Windows.Point in ClickablePointProperty: {0}",
					                            clickablePoint.GetType ()));
				}

				object boundingRectangle
					= provider.GetPropertyValue (AutomationElementIdentifiers.BoundingRectangleProperty.Id);
				Assert.IsNotNull (boundingRectangle, 
				                  "You need to return BoundingRectangle if you return ClickablePointProperty.");

				try {
					Rect boundingRectangleRect = (Rect) boundingRectangle;
					Assert.AreNotEqual (Rect.Empty, 
					                    boundingRectangleRect,
					                    "BoundingRectangle SHOULD NOT be Rect.Empty");

					Rect clickablePointRect = new Rect (clickablePoint.X, clickablePoint.Y, 1, 1);

					Assert.IsTrue (boundingRectangleRect.Contains (clickablePointRect),
					               string.Format ("ClickablePoint ({0}) SHOULD Intersect with BoundingRectangle: {1}",
					                              clickablePointRect.ToString (), 
					                              boundingRectangleRect.ToString ()));
					
				} catch (InvalidCastException) {
					Assert.Fail (string.Format ("You are not returning System.Windows.Rect in BoundingRectangle: {0}",
					                            boundingRectangle.GetType ()));
				}
			}
		}
开发者ID:mono,项目名称:uia2atk,代码行数:70,代码来源:BaseProviderTest.cs

示例7: Equals

        /// <summary>
        /// Compares for reference AND value equality.
        /// </summary>
        /// <param name="obj">The object to compare with this instance.</param>
        /// <returns>
        /// 	<c>true</c> if both operands are equal; otherwise, <c>false</c>.
        /// </returns>
        public bool Equals(Point obj)
        {
            bool ivarsEqual = true;

            if (obj.GetType() != this.GetType())
            {
                return false;
            }

            if (this._x != obj._x)
            {
                ivarsEqual = false;
            }

            if (this._y != obj._y)
            {
                ivarsEqual = false;
            }

            return ivarsEqual;
        }
开发者ID:mcgredonps,项目名称:open-dis-csharp,代码行数:28,代码来源:Point.cs

示例8: equals

        /**
          * The equals method doesn't always work--mostly on on classes that consist only of primitives. Be careful.
          */
        public bool equals(Point rhs)
        {
            bool ivarsEqual = true;

            if(rhs.GetType() != this.GetType())
            return false;

             if( ! (_x == rhs._x)) ivarsEqual = false;
             if( ! (_y == rhs._y)) ivarsEqual = false;

            return ivarsEqual;
        }
开发者ID:mcgredonps,项目名称:open-dis-csharp,代码行数:15,代码来源:Point.cs

示例9: XMLDeserializer

        private static Point XMLDeserializer()
        {
            FileStream stream = new FileStream("data.xml", FileMode.Open, FileAccess.Read);

            Point p = new Point();

            XmlSerializer serializer = new XmlSerializer(p.GetType());
            p = (Point)serializer.Deserialize(stream);

            stream.Close();

            return p;
        }
开发者ID:CS302,项目名称:Group16,代码行数:13,代码来源:Program.cs


注:本文中的Point.GetType方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。