当前位置: 首页>>代码示例>>C#>>正文


C# Duration.Equals方法代码示例

本文整理汇总了C#中Duration.Equals方法的典型用法代码示例。如果您正苦于以下问题:C# Duration.Equals方法的具体用法?C# Duration.Equals怎么用?C# Duration.Equals使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Duration的用法示例。


在下文中一共展示了Duration.Equals方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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();
        }
开发者ID:dirkrombauts,项目名称:NFluent,代码行数:21,代码来源:DurationTests.cs

示例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));
        }
开发者ID:rhwy,项目名称:NFluent,代码行数:24,代码来源:TimeHelperTest.cs

示例3: Equals

 public static bool Equals(Duration t1, Duration t2)
 {
     return t1.Equals(t2);
 }
开发者ID:Alantoo,项目名称:corefx,代码行数:4,代码来源:Duration.cs

示例4: Equals

        //=====================================================================

        /// <summary>
        /// Returns a value indicating whether two specified instances of <c>Duration</c> are equal
        /// </summary>
        /// <param name="d1">The first duration to compare</param>
        /// <param name="d2">The second duration to compare</param>
        /// <returns>Returns true if the durations are equal, false if they are not</returns>
        public static bool Equals(Duration d1, Duration d2)
        {
            if((object)d1 == null && (object)d2 == null)
                return true;

            if((object)d1 == null)
                return false;

            return d1.Equals(d2);
        }
开发者ID:modulexcite,项目名称:PDI,代码行数:18,代码来源:Duration.cs


注:本文中的Duration.Equals方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。