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


C# Pair.Equals方法代码示例

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


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

示例1: TestEquals

 public void TestEquals()
 {
     Pair<string, string> test = new Pair<string, string>("a", "b");
     Assert.False(test.Equals((object)null));
     Assert.False(test.Equals(this));
     Assert.True(test.Equals((object)test));
     Assert.True(test.Equals((object)new Pair<string, string>("a", "b")));
 }
开发者ID:Joxx0r,项目名称:ATF,代码行数:8,代码来源:TestPair.cs

示例2: TestEqualsTargetDifferent

 public void TestEqualsTargetDifferent()
 {
     var first = new Pair<int>(5, 6);
     var second = new Pair<int>(5, 14);
     Assert.IsFalse(first.Equals(second));
     Assert.IsFalse(second.Equals(first));
 }
开发者ID:MainMa,项目名称:mockeverything,代码行数:7,代码来源:PairTests.cs

示例3: TestEqualsAllSame

 public void TestEqualsAllSame()
 {
     var first = new Pair<int>(5, 6);
     var second = new Pair<int>(5, 6);
     Assert.IsTrue(first.Equals(second));
     Assert.IsTrue(second.Equals(first));
 }
开发者ID:MainMa,项目名称:mockeverything,代码行数:7,代码来源:PairTests.cs

示例4: EqualPairsAreEqual

        public void EqualPairsAreEqual()
        {
            var a = new Pair<int, string>(10, "ABC");
            var b = new Pair<int, string>(10, "ABC");

            bool result = a.Equals(b);

            Assert.IsTrue(result);
        }
开发者ID:ondrejsevcik,项目名称:PieceOfCake,代码行数:9,代码来源:Tests.cs

示例5: Pair_full_test

 public void Pair_full_test()
 {
     Pair<int> pair = new Pair<int>(1, 2);
     Assert.AreEqual(1, pair.First);
     Assert.AreEqual(2, pair.Second);
     Assert.IsTrue(pair.Contains(1));
     Assert.IsTrue(pair.Contains(2));
     Assert.IsTrue(!pair.Contains(3));
     Assert.IsTrue(Pair<int>.PerformTest(TestPairFunction, pair.First, pair.Second));
     Assert.IsTrue(pair.Equals(new Pair<int>(2, 1)));
 }
开发者ID:rumothy,项目名称:pong,代码行数:11,代码来源:PairTest.cs

示例6: TestPairs

 static void TestPairs()
 {
     Pair<string, int> pair = new Pair<string, int>("string4e", 42);
     Pair<string, int> pair2 = new Pair<string, int>("drugoStringche", 42);
     Pair<string, int> pair3 = new Pair<string, int>("string4e", 42);
     Console.WriteLine(pair);
     Console.WriteLine(pair2);
     Console.WriteLine(pair3);
     Console.WriteLine(pair == pair3);
     Console.WriteLine(pair.Equals(pair2));
 }
开发者ID:rokn,项目名称:HackBulgaria,代码行数:11,代码来源:Program.cs

示例7: Main

        static void Main(string[] args)
        {
            Pair<string> pair1 = new Pair<string>();
            Pair<string> pair2 = new Pair<string>();
            pair1.X = "bla";
            pair2.X = "bla";
            pair1.Y = "be";
            pair2.Y = "be";
            Console.WriteLine(pair1.Equals(pair2));

            Pair<int> pair3 = new Pair<int>(4, 5);
            Pair<int> pair4 = new Pair<int>(3, 6);
            Console.WriteLine(pair3.Equals(pair4));
            Console.WriteLine(pair3);
        }
开发者ID:StefanGovedarski,项目名称:HackBulgariaHomeworks,代码行数:15,代码来源:Program.cs

示例8: AddRoute

        /// <summary>
        /// Add an entry to the route table.
        /// Adds a route or not depending on all the different sates that
        /// the route table can be in.
        /// </summary>
        /// <param name="newRoute">
        /// is a pair (addr,hash) where addr is the socket address for
        /// some server and hash is the first hash in that server's range
        /// If the number of entries in the table exceeds the max number
        /// allowed, the first entry that does not refer to the successor
        /// of this server, is removed.If debug is true and the set of
        /// stored routes does change, print the string "rteTbl=" +
        /// rteTbl. (IMPORTANT)</param>
        private void AddRoute(Pair<IPEndPoint, int> newRoute)
        {
            var myPair = new Pair<IPEndPoint, int>(_address, _hashRange.Second);

            //Does not add null routes or this server itself to the table.
            if (newRoute == null || newRoute.Equals(myPair))
            {
                return;
            }

            //Iterate over the routing table so that we do not add repeating routes.
            foreach (var element in _routesTable)
            {
                if (element.Equals(newRoute))
                {
                    return;
                }
            }

            //Consider the cases when the size of the routing table is at its limit.
            if (_routesTable.Count >= _numRoutes)
            {
                if (_routesTable.Count == 1 && _routesTable[0].Equals(_succInfo))
                {
                    return;
                }

                int rm_index = _routesTable[0].Equals(_succInfo) ? 1 : 0;
                _routesTable.RemoveAt(rm_index);
            }

            //Add the new route.
            var routeToAdd = new Pair<IPEndPoint, int>(newRoute.First, newRoute.Second);

            _routesTable.Add(routeToAdd);

            //Print the debug routing table.
            //if (debug)
            //    System.out.println("rteTbl=" + rteTbl);
        }
开发者ID:Lewis945,项目名称:DS-HW3,代码行数:53,代码来源:Server.cs

示例9: TestEqualsPair

 public void TestEqualsPair()
 {
     Pair<string, string> test = new Pair<string, string>("a", "b");
     Assert.True(test.Equals(test));
     Assert.True(test.Equals(new Pair<string, string>("a", "b")));
 }
开发者ID:Joxx0r,项目名称:ATF,代码行数:6,代码来源:TestPair.cs

示例10: EqualsTest

 public void EqualsTest()
 {
     Pair<int, String> p1 = new Pair<int, string>();
       Pair<int, String> p2 = new Pair<int, string>();
       Assert.IsTrue(p1.Equals(p1));
       Assert.IsTrue(p1.Equals((object)p1));
       Assert.IsFalse(p1.Equals(null));
       Assert.IsFalse(p1.Equals((object)null));
       Assert.IsTrue(p1.Equals(p2));
       Assert.IsTrue(p1 == p2);
       Assert.IsFalse(p1 != p2);
       p1.First = 12;
       Assert.IsFalse(p1.Equals(p2));
       Assert.IsFalse(p1 == p2);
       Assert.IsTrue(p1 != p2);
       p2.First = 12;
       Assert.IsTrue(p1.Equals(p2));
       p1.Second = "Hallo";
       Assert.IsFalse(p1.Equals(p2));
       p2.Second = "Hallo";
       Assert.IsTrue(p1.Equals(p2));
       p1.First = 13;
       Assert.IsFalse(p1.Equals(p2));
       p2.First = 13;
       Assert.IsTrue(p1.Equals(p2));
       p1.Second = "Hallo2";
       Assert.IsFalse(p1.Equals(p2));
 }
开发者ID:Zolniu,项目名称:DigitalRune,代码行数:28,代码来源:Pair2Test.cs

示例11: TestEqualsWrongType

 public void TestEqualsWrongType()
 {
     var first = new Pair<int>(5, 6);
     Assert.IsFalse(first.Equals(27));
 }
开发者ID:MainMa,项目名称:mockeverything,代码行数:5,代码来源:PairTests.cs

示例12: TestEqualsNull

 public void TestEqualsNull()
 {
     var first = new Pair<int>(5, 6);
     Assert.IsFalse(first.Equals(null));
 }
开发者ID:MainMa,项目名称:mockeverything,代码行数:5,代码来源:PairTests.cs

示例13: EqualsTest

        public void EqualsTest()
        {
            Pair<int> p1 = new Pair<int>();
              Pair<int> p2 = new Pair<int>();
              Assert.IsTrue(p1.Equals(p1));
              Assert.IsTrue(p1.Equals((object)p1));
              Assert.IsFalse(p1.Equals(null));
              Assert.IsFalse(p1.Equals((object)null));
              Assert.IsTrue(p1.Equals(p2));
              Assert.IsTrue(p1 == p2);
              Assert.IsFalse(p1 != p2);
              p1.First = 12;
              Assert.IsFalse(p1.Equals(p2));
              Assert.IsFalse(p1 == p2);
              Assert.IsTrue(p1 != p2);
              p2.First = 12;
              Assert.IsTrue(p1.Equals(p2));
              p1.Second = 34;
              Assert.IsFalse(p1.Equals(p2));
              p2.Second = 34;
              Assert.IsTrue(p1.Equals(p2));
              p1.First = 13;
              Assert.IsFalse(p1.Equals(p2));
              p2.First = 13;
              Assert.IsTrue(p1.Equals(p2));

              p1.First = p2.Second;
              p1.Second = p2.First;
              Assert.IsTrue(p1.Equals(p2));
        }
开发者ID:Zolniu,项目名称:DigitalRune,代码行数:30,代码来源:Pair1Test.cs


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