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


C# Point.GetHashCode方法代码示例

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


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

示例1: Point

 public void Point()
 {
     //Do various Point method calls to cover the point class with sufficient testing
     Point p0 = new Point();
     Point p1 = new Point(0, 0);
     Point p2 = new Point(450, 120);
     Assert.IsTrue(p0.IsEmpty());
     Assert.IsFalse(p1.IsEmpty());
     Assert.AreNotEqual(p0, p1);
     Assert.AreEqual(450, p2.X);
     Assert.AreEqual(120, p2.Y);
     Assert.AreNotSame(p2.Clone(), p2);
     p0 = p2.Clone();
     p0.X += 100;
     p0.Y = 150;
     p0[0] += p0[1];
     Assert.AreEqual(new Point(700, 150), p0);
     Assert.AreEqual(p2, p2.GetBoundingBox().Min);
     Assert.AreEqual(p2, p2.GetBoundingBox().Max);
     Assert.IsTrue(p2.IsSimple());
     Assert.IsFalse(p2.IsEmpty());
     Assert.AreEqual(2, p2.NumOrdinates);
     Assert.AreEqual(new Point(400, 100), p2 + new Point(-50, -20));
     Assert.AreEqual(new Point(500, 100), p2 - new Point(-50, 20));
     Assert.AreEqual(new Point(900, 240), p2*2);
     Assert.AreEqual(0, p2.Dimension);
     Assert.AreEqual(450, p2[0]);
     Assert.AreEqual(120, p2[1]);
     Assert.IsNull(p2.Boundary());
     Assert.AreEqual(p2.X.GetHashCode() ^ p2.Y.GetHashCode() ^ p2.IsEmpty().GetHashCode(), p2.GetHashCode());
     Assert.Greater(p2.CompareTo(p1), 0);
     Assert.Less(p1.CompareTo(p2), 0);
     Assert.AreEqual(p2.CompareTo(new Point(450, 120)), 0);
 }
开发者ID:geobabbler,项目名称:SharpMap,代码行数:34,代码来源:PointTests.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: Equals_IsTrue

        public void Equals_IsTrue (int p1x, int p1y, int p2x, int p2y)
        {
            var p1 = new Point(p1x, p1y);
            var p2 = new Point(p2x, p2y);

            (p1 == p2).Should().BeTrue();
            (p1 != p2).Should().BeFalse();
            (p1.GetHashCode() == p2.GetHashCode()).Should().BeTrue();
        }
开发者ID:jhorv,项目名称:CsConsoleFormat,代码行数:9,代码来源:PointTests.cs

示例4: GetHashCodeTakesYIntoAccount

        public void GetHashCodeTakesYIntoAccount()
        {
            var point = new Point(1, 2);

            var c1 = point.GetHashCode();

            point.Y = 3;
            Assert.AreNotEqual(c1, point.GetHashCode());
        }
开发者ID:lishxi,项目名称:_SharpMap,代码行数:9,代码来源:GeometryTest.cs

示例5: EqualityTest

        public void EqualityTest(int x, int y)
        {
            Point p1 = new Point(x, y);
            Point p2 = new Point(x / 2 - 1, y / 2 - 1);
            Point p3 = new Point(x, y);

            Assert.True(p1 == p3);
            Assert.True(p1 != p2);
            Assert.True(p2 != p3);

            Assert.True(p1.Equals(p3));
            Assert.False(p1.Equals(p2));
            Assert.False(p2.Equals(p3));

            Assert.Equal(p1.GetHashCode(), p3.GetHashCode());
        }
开发者ID:er0dr1guez,项目名称:corefx,代码行数:16,代码来源:PointTests.cs

示例6: GetHashCodeTest

 public static void GetHashCodeTest()
 {
     var point = new Point(10, 10);
     Assert.Equal(point.GetHashCode(), new Point(10, 10).GetHashCode());
     Assert.NotEqual(point.GetHashCode(), new Point(20, 10).GetHashCode());
     Assert.NotEqual(point.GetHashCode(), new Point(10, 20).GetHashCode());
 }
开发者ID:Corillian,项目名称:corefx,代码行数:7,代码来源:PointTests.cs

示例7: CheckCollisionWhitOtherObject

    private bool CheckCollisionWhitOtherObject(Point point)
    {
        bool haveCollision = false;

        foreach (var obj in gameObjectsList)
        {
            foreach (var o in obj.PositionsCoordinates)
            {
                if (point.GetHashCode() == o.GetHashCode())
                {
                    obj.HaveCollision = true;
                    return true;
                }
            }
        }

        return haveCollision;
    }
开发者ID:TominaP,项目名称:Fermi-in-the-air,代码行数:18,代码来源:Engine.cs

示例8: CheckCollisionWhitCollectedObject

    private bool CheckCollisionWhitCollectedObject(Point currentPoint)
    {
        bool isCollectedObject = false;

        foreach (var obj in gameObjectsList)
        {
            foreach (var point in obj.PositionsCoordinates)
            {
                if (point.GetHashCode() == currentPoint.GetHashCode())
                {
                    if (obj is CollectedObject)
                    {
                        return true;
                    }
                }
            }
        }

        return isCollectedObject;
    }
开发者ID:TominaP,项目名称:Fermi-in-the-air,代码行数:20,代码来源:Engine.cs

示例9: Point_GetHashCode_returns_same_hash_for_same_object

 public void Point_GetHashCode_returns_same_hash_for_same_object()
 {
     var p1 = new Point(1.0f, 1.2f, 1.9f);
     var p2 = p1;
     var hash1 = p1.GetHashCode();
     var hash2 = p2.GetHashCode();
     Assert.AreEqual(hash1, hash2);
 }
开发者ID:EddPorter,项目名称:RayManCS,代码行数:8,代码来源:PointTests.cs

示例10: Point_GetHashCode_returns_different_hashes_for_different_objects

 public void Point_GetHashCode_returns_different_hashes_for_different_objects()
 {
     var p1 = new Point(1.0f, 1.2f, 1.9f);
     var p2 = new Point(-1.0f, -1.2f, -1.9f);
     var hash1 = p1.GetHashCode();
     var hash2 = p2.GetHashCode();
     Assert.AreNotEqual(hash1, hash2);
 }
开发者ID:EddPorter,项目名称:RayManCS,代码行数:8,代码来源:PointTests.cs

示例11: Point_GetHashCode_returns

 public void Point_GetHashCode_returns()
 {
     var p = new Point(1.0f, 1.2f, 1.9f);
     p.GetHashCode();
 }
开发者ID:EddPorter,项目名称:RayManCS,代码行数:5,代码来源:PointTests.cs


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