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


C# ComplexNumber.Equals方法代码示例

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


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

示例1: Simple1

        public void Simple1()
        {
            object complexNumber1 = new ComplexNumber(1, 2);
            object complexNumber2 = new ComplexNumber(1, 2);
            object complexNumber3 = new ComplexNumber(1, 6);
            object complexNumber4 = new ComplexNumber(2, 2);
            object complexNumber5 = new ComplexNumber(3, 3);

            Assert.IsTrue(complexNumber1.Equals(complexNumber1));
            Assert.IsTrue(complexNumber1.Equals(complexNumber2));
            Assert.IsFalse(complexNumber1.Equals(complexNumber3));
            Assert.IsFalse(complexNumber1.Equals(complexNumber4));
            Assert.IsFalse(complexNumber1.Equals(complexNumber5));
        }
开发者ID:GTuritto,项目名称:ngenerics,代码行数:14,代码来源:EqualsObj.cs

示例2: EqualsTest

        public void EqualsTest()
        {
            var exp1 = new ComplexNumber(new Complex(5, 2));
            var exp2 = new ComplexNumber(new Complex(5, 2));

            Assert.True(exp1.Equals(exp2));
        }
开发者ID:sys27,项目名称:xFunc,代码行数:7,代码来源:ComplexNumberTest.cs

示例3: Simple3

        public void Simple3()
        {
            object complexNumber1 = new ComplexNumber(1, 2);
            var complexNumber2 = new object();

            Assert.IsFalse(complexNumber1.Equals(complexNumber2));
            Assert.IsFalse(complexNumber1.Equals(null));
        }
开发者ID:GTuritto,项目名称:ngenerics,代码行数:8,代码来源:EqualsObj.cs

示例4: Simple2

        public void Simple2()
        {
            var complexNumber1 = new ComplexNumber(1, 2);
            var complexNumber2 = new ComplexNumber(1, 2);
            var complexNumber3 = new ComplexNumber(1, 6);
            var complexNumber4 = new ComplexNumber(2, 2);
            var complexNumber5 = new ComplexNumber(3, 3);

            Assert.IsTrue(complexNumber1.Equals(complexNumber1));
            Assert.IsTrue(complexNumber1.Equals(complexNumber2));
            Assert.IsFalse(complexNumber1.Equals(complexNumber3));
            Assert.IsFalse(complexNumber1.Equals(complexNumber4));
            Assert.IsFalse(complexNumber1.Equals(complexNumber5));

            // Disable warning C1718 : Testing equality of same variable
            #pragma warning disable 1718

            Assert.IsTrue(complexNumber1 == complexNumber1);

            #pragma warning restore 1718

            Assert.IsTrue(complexNumber1 == complexNumber2);
            Assert.IsFalse(complexNumber1 == complexNumber3);
            Assert.IsFalse(complexNumber1 == complexNumber4);
            Assert.IsFalse(complexNumber1 == complexNumber5);

            #pragma warning disable 1718

            Assert.IsFalse(complexNumber1 != complexNumber1);

            #pragma warning restore 1718

            Assert.IsFalse(complexNumber1 != complexNumber2);
            Assert.IsTrue(complexNumber1 != complexNumber3);
            Assert.IsTrue(complexNumber1 != complexNumber4);
            Assert.IsTrue(complexNumber1 != complexNumber5);
        }
开发者ID:GTuritto,项目名称:ngenerics,代码行数:37,代码来源:EqualsObj.cs

示例5: NotEqualsTest

        public void NotEqualsTest()
        {
            var exp1 = new ComplexNumber(new Complex(5, 2));
            var exp2 = new ComplexNumber(new Complex(3, 2));

            Assert.False(exp1.Equals(exp2));
        }
开发者ID:sys27,项目名称:xFunc,代码行数:7,代码来源:ComplexNumberTest.cs

示例6: EqualsObjectExample

        public void EqualsObjectExample()
        {
            object complexNumber1 = new ComplexNumber(1, 2);
            object complexNumber2 = new ComplexNumber(1, 2);

            Assert.IsTrue(complexNumber1.Equals(complexNumber1));
            Assert.IsTrue(complexNumber1.Equals(complexNumber2));
        }
开发者ID:havok,项目名称:ngenerics,代码行数:8,代码来源:ComplexNumberExamples.cs

示例7: EqualsExample

        public void EqualsExample()
        {
            var complexNumber1 = new ComplexNumber(1, 2);
            var complexNumber2 = new ComplexNumber(1, 2);

            Assert.IsTrue(complexNumber1.Equals(complexNumber1));
            Assert.IsTrue(complexNumber1.Equals(complexNumber2));
        }
开发者ID:havok,项目名称:ngenerics,代码行数:8,代码来源:ComplexNumberExamples.cs

示例8: AssertTrueNonEquality

 private static void AssertTrueNonEquality(ComplexNumber a, ComplexNumber b, string message)
 {
     Assert.IsTrue(a != b, message);
     Assert.IsFalse(a.Equals((object)b), message);
     Assert.IsFalse(((IEquatable<ComplexNumber>)a).Equals(b), message);
 }
开发者ID:bazile,项目名称:Training,代码行数:6,代码来源:ComplexNumberFixture.cs

示例9: CanCompareWithNull

        public void CanCompareWithNull()
        {
            var x = new ComplexNumber(0);
            Assert.IsTrue(x != null);
            Assert.IsTrue(null != x);
            Assert.IsFalse(x == null);
            Assert.IsFalse(null == x);
            Assert.IsFalse(x.Equals(null), "x.Equals(null)");

            x = null;
            ComplexNumber y = null;
            Assert.IsTrue(x == y);
            Assert.IsFalse(x != y);
        }
开发者ID:bazile,项目名称:Training,代码行数:14,代码来源:ComplexNumberFixture.cs


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