本文整理汇总了C#中Prefix.Equals方法的典型用法代码示例。如果您正苦于以下问题:C# Prefix.Equals方法的具体用法?C# Prefix.Equals怎么用?C# Prefix.Equals使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Prefix
的用法示例。
在下文中一共展示了Prefix.Equals方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: GetPrefixedUnit
/// <summary>
/// Gets the prefixed unit.
/// </summary>
/// <param name="newPrefix">The prefix.</param>
/// <returns>A new <see cref="IUnit"/> with the specified <see cref="Prefix"/>.</returns>
public IUnit GetPrefixedUnit(Prefix newPrefix)
{
if (newPrefix.Equals(this.prefixedBaseUnit.Prefix))
{
return this.prefixedBaseUnit;
}
return new NotationBaseUnit(newPrefix, this.Notation, this.prefixedBaseUnit);
}
示例2: TestPrefixEquality
public void TestPrefixEquality()
{
// Object setup
object obj1 = new object();
Prefix p1 = new Prefix();
Prefix p2 = new Prefix();
Prefix p3 = new Prefix("Hello", "World", "Foobar");
Prefix p4 = new Prefix("Hello", "World", "Foobar");
Prefix p5 = null;
Prefix p6 = p1;
// Equality
Assert.IsTrue(Prefix.Equals(p1, p2));
Assert.IsTrue(p1.Equals(p2));
Assert.IsTrue(p1 == p2);
Assert.IsTrue(Prefix.Equals(p3, p4));
Assert.IsTrue(p3.Equals(p4));
Assert.IsTrue(p3 == p4);
// Inequality
Assert.IsFalse(p1.Equals(obj1));
Assert.IsFalse(Prefix.Equals(p1, obj1));
Assert.IsFalse(Prefix.Equals(p1, p3));
Assert.IsFalse(p1.Equals(p3));
Assert.IsTrue(p1 != p3);
Assert.IsFalse(Prefix.Equals(p2, p4));
Assert.IsFalse(p2.Equals(p4));
Assert.IsTrue(p2 != p4);
// Checks against null objects
Assert.IsFalse(Prefix.Equals(p1, p5));
Assert.IsFalse(Prefix.Equals(p5, p1));
Assert.IsTrue(p1 != p5);
Assert.IsTrue(p5 != p1);
// Checks against null
Assert.IsFalse(p1.Equals(null));
Assert.IsTrue(Prefix.Equals(p5, null));
Assert.IsTrue(Prefix.Equals(null, p5));
Assert.IsTrue(p5 == null);
Assert.IsTrue(null == p5);
// Checks against self
Assert.IsTrue(p1.Equals(p6));
// Checks against null or invalid
Assert.IsTrue(Prefix.IsNullOrNotExists(p1));
Assert.IsTrue(Prefix.IsNullOrNotExists(p2));
Assert.IsFalse(Prefix.IsNullOrNotExists(p3));
Assert.IsFalse(Prefix.IsNullOrNotExists(p4));
Assert.IsTrue(Prefix.IsNullOrNotExists(p5));
// Hash codes are equal;
Assert.IsTrue(p1.GetHashCode() == p2.GetHashCode());
Assert.IsTrue(p3.GetHashCode() == p4.GetHashCode());
}