本文整理汇总了C#中Tuple.GetHashCode方法的典型用法代码示例。如果您正苦于以下问题:C# Tuple.GetHashCode方法的具体用法?C# Tuple.GetHashCode怎么用?C# Tuple.GetHashCode使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Tuple
的用法示例。
在下文中一共展示了Tuple.GetHashCode方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: GetHashCodeIsTheSame
public void GetHashCodeIsTheSame()
{
var sut2 = new Tuple<int, string>(integer, stringy);
Assert.Equal(sut2.GetHashCode(), sut.GetHashCode());
}
示例2: Value_type_tuple
public void Value_type_tuple()
{
// This is a bit contrived, just need an easy class (ie non-value type)
var helper = new IdHelperForClassType<Tuple<int, int>>();
var tuple1 = new Tuple<int, int>(1, 2);
var tuple2 = new Tuple<int, int>(1, 3);
var tuple1Again = new Tuple<int, int>(1, 2);
Assert.AreEqual(true, helper.IsNull(null));
Assert.AreEqual(true, helper.IsDefaultValue(null));
Assert.AreEqual(false, helper.IsDefaultValue(tuple1));
Assert.AreEqual(true, helper.AreEqual(null, null));
Assert.AreEqual(true, helper.AreEqual(tuple1, tuple1Again));
Assert.AreEqual(-1, helper.Compare(null, tuple1));
Assert.AreEqual(-1, helper.Compare(tuple1, tuple2));
Assert.AreEqual(+1, helper.Compare(tuple2, null));
Assert.AreEqual(+1, helper.Compare(tuple2, tuple1));
Assert.That(helper.Compare(null, null), Is.EqualTo(0));
Assert.AreEqual(0, helper.Compare(tuple1, tuple1Again));
Assert.AreEqual(tuple1.GetHashCode(), helper.GetHashCode(tuple1));
Assert.AreEqual(0, helper.GetHashCode(null));
}
示例3: CanHashCodeTwoFiveSizedNullableTuples
public void CanHashCodeTwoFiveSizedNullableTuples()
{
var tuple1 = new Tuple<int?>(1, 2, null, 4, 5);
var tuple2 = new Tuple<int?>(1, 2, null, 4, 5);
var tuple3 = new Tuple<int?>(1, 2, 3, 4, null);
tuple2.GetHashCode().Should().Be(tuple1.GetHashCode());
tuple3.GetHashCode().Should().Not.Be(tuple1.GetHashCode());
}
示例4: GetHashCodeIsDifferent
public void GetHashCodeIsDifferent()
{
var sut2 = new Tuple<int, string>(integer + 1, stringy);
Assert.NotEqual(sut2.GetHashCode(), sut.GetHashCode());
}
示例5: CannotHashCodeTwoDifferentSizesTuples
public void CannotHashCodeTwoDifferentSizesTuples()
{
var tuple1 = new Tuple<int>(1, 2, 3, 4, 5);
var tuple2 = new Tuple<int>(1, 2, 3, 4, 5, 6);
tuple2.GetHashCode().Should().Not.Be(tuple1.GetHashCode());
}
示例6: CanHashCodeTwoFiveSizedTuples
public void CanHashCodeTwoFiveSizedTuples()
{
var tuple1 = new Tuple<int>(1, 2, 3, 4, 5);
var tuple2 = new Tuple<int>(1, 2, 3, 4, 5);
var tuple3 = new Tuple<int>(1, 2, 3, 4, 6);
tuple2.GetHashCode().Should().Be(tuple1.GetHashCode());
tuple3.GetHashCode().Should().Not.Be(tuple1.GetHashCode());
}
示例7: GetHashCodeIsTheSame
public void GetHashCodeIsTheSame()
{
var sut2 = new Tuple<int, string>(integer, stringy);
sut.GetHashCode().ShouldEqual(sut2.GetHashCode());
}
示例8: GetHashCode
public static int GetHashCode(Tuple<string, string> fromStatusSubStatus, Tuple<string, string> toStatusSubStatus)
{
return (fromStatusSubStatus.GetHashCode() << 8) + toStatusSubStatus.GetHashCode();
}
示例9: GetHashCode
public override int GetHashCode()
{
var tuple = new Tuple<string, string> (Id, Destination);
return tuple.GetHashCode ();
}