本文整理汇总了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));
}
示例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));
}
示例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));
}
示例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);
}
示例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));
}
示例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));
}
示例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));
}
示例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);
}
示例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);
}