本文整理汇总了C#中BigDecimal.GetHashCode方法的典型用法代码示例。如果您正苦于以下问题:C# BigDecimal.GetHashCode方法的具体用法?C# BigDecimal.GetHashCode怎么用?C# BigDecimal.GetHashCode使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类BigDecimal
的用法示例。
在下文中一共展示了BigDecimal.GetHashCode方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Hash
public static int Hash(BigDecimal/*!*/ self) {
return self.GetHashCode();
}
示例2: TestGetHashCode
public void TestGetHashCode()
{
// anything that is equal must have the same hashCode
BigDecimal hash = BigDecimal.Parse("1.00");
BigDecimal hash2 = new BigDecimal(1.00D);
Assert.IsTrue(hash.GetHashCode() != hash2.GetHashCode() && !hash.Equals(hash2),
"the hashCode of 1.00 and 1.00D is equal");
hash2 = BigDecimal.Parse("1.0");
Assert.IsTrue(hash.GetHashCode() != hash2.GetHashCode() && !hash.Equals(hash2),
"the hashCode of 1.0 and 1.00 is equal");
BigInteger val = BigInteger.Parse("100");
hash2 = new BigDecimal(val, 2);
Assert.IsTrue(hash.GetHashCode() == hash2.GetHashCode() && hash.Equals(hash2),
"hashCode of 1.00 and 1.00(bigInteger) is not equal");
hash = new BigDecimal(value, 2);
hash2 = BigDecimal.Parse("-1233456.0000");
Assert.IsTrue(hash.GetHashCode() != hash2.GetHashCode() && !hash.Equals(hash2),
"hashCode of 123459.08 and -1233456.0000 is not equal");
hash2 = new BigDecimal(value.Negate(), 2);
Assert.IsTrue(hash.GetHashCode() != hash2.GetHashCode() && !hash.Equals(hash2),
"hashCode of 123459.08 and -123459.08 is not equal");
}