本文整理汇总了C#中Duration.GetHashCode方法的典型用法代码示例。如果您正苦于以下问题:C# Duration.GetHashCode方法的具体用法?C# Duration.GetHashCode怎么用?C# Duration.GetHashCode使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Duration
的用法示例。
在下文中一共展示了Duration.GetHashCode方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: TestDurationClass
public void TestDurationClass()
{
var firstDuration = new Duration(200, TimeUnit.Minutes);
Check.That(firstDuration.RawDuration).IsEqualTo(200);
Check.That(firstDuration.Unit).IsEqualTo(TimeUnit.Minutes);
Check.That(firstDuration.ToString()).IsEqualTo("200 Minutes");
Check.That(firstDuration > new Duration(100, TimeUnit.Seconds)).IsTrue();
Check.That(firstDuration < new Duration(100, TimeUnit.Hours)).IsTrue();
var anotherDurationWithSameValue = new Duration(200, TimeUnit.Minutes);
// test objects override
Check.That(firstDuration.GetHashCode()).IsEqualTo(anotherDurationWithSameValue.GetHashCode());
Check.That(firstDuration).IsEqualTo(anotherDurationWithSameValue);
Check.That(anotherDurationWithSameValue.Equals(firstDuration)).IsTrue();
Check.That(anotherDurationWithSameValue == firstDuration).IsTrue();
Check.That(anotherDurationWithSameValue.Equals(null)).IsFalse();
Check.That(anotherDurationWithSameValue.Equals(20)).IsFalse();
Check.That(anotherDurationWithSameValue.Equals((object)firstDuration)).IsTrue();
}
示例2: TestDurationClass
public void TestDurationClass()
{
var test = new Duration(200, TimeUnit.Minutes);
Assert.AreEqual(200, test.RawDuration);
Assert.AreEqual(TimeUnit.Minutes, test.Unit);
Assert.AreEqual("200 Minutes", test.ToString());
Assert.IsTrue(test > new Duration(100, TimeUnit.Seconds));
Assert.IsTrue(test < new Duration(100, TimeUnit.Hours));
var altDuration = new Duration(200, TimeUnit.Minutes);
// test objects override
Assert.AreEqual(altDuration.GetHashCode(), test.GetHashCode());
Assert.AreEqual(altDuration, test);
Assert.IsTrue(altDuration.Equals(test));
Assert.IsTrue(altDuration == test);
Assert.IsFalse(altDuration.Equals(null));
Assert.IsFalse(altDuration.Equals(20));
Assert.IsTrue(altDuration.Equals((object)test));
}