本文整理汇总了C#中Length.Equals方法的典型用法代码示例。如果您正苦于以下问题:C# Length.Equals方法的具体用法?C# Length.Equals怎么用?C# Length.Equals使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Length
的用法示例。
在下文中一共展示了Length.Equals方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: doit
public static void doit()
{
new LengthTest().hashCode();
Length l = new Length(10.1234, LengthType.mm);
double d = 10.1234;
for (int i = 0; i < 100; i++)
{
d = d / 7;
}
for (int i = 0; i < 100; i++)
{
d = d * 7;
}
Length l2 = new Length(d, LengthType.cm);
Console.WriteLine(l);
Console.WriteLine(new Length());
Console.WriteLine(l.ToCM());
Console.WriteLine(l.ToKM());
Console.WriteLine(l.ToM());
Console.WriteLine(new Length(1, LengthType.km).ToCM());
//Console.WriteLine(l2.ToString("n0"));
Console.WriteLine(l2.Value);
Console.WriteLine(l.GetHashCode() + " " + l2.GetHashCode());
Console.WriteLine(l.Equals(l2));
}
示例2: OpEquals
public void OpEquals()
{
var length1 = new Length(3000, LengthUnit.Meter);
var length2 = new Length(3, LengthUnit.Kilometer);
var length3 = new Length(4, LengthUnit.Kilometer);
(length1 == length2).ShouldBeTrue();
(length2 == length1).ShouldBeTrue();
(length1 == length3).ShouldBeFalse();
(length3 == length1).ShouldBeFalse();
length1.Equals(length2)
.ShouldBeTrue();
length1.Equals((object)length2)
.ShouldBeTrue();
length2.Equals(length1)
.ShouldBeTrue();
length2.Equals((object)length1)
.ShouldBeTrue();
}
示例3: EqualsLengthTest
public void EqualsLengthTest()
{
Length target = new Length(10F);
Length obj = new Length(10F);
bool expected = true;
bool actual;
actual = target.Equals(obj);
Assert.AreEqual(expected, actual);
}
示例4: EqualsDoubleTest
public void EqualsDoubleTest()
{
Length target = new Length(10F);
double obj = 10F;
bool expected = true;
bool actual;
actual = target.Equals(obj);
Assert.AreEqual(expected, actual);
}