本文整理汇总了C#中System.Date.Equals方法的典型用法代码示例。如果您正苦于以下问题:C# Date.Equals方法的具体用法?C# Date.Equals怎么用?C# Date.Equals使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Date
的用法示例。
在下文中一共展示了Date.Equals方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: CanConstructFromDateTime
public void CanConstructFromDateTime()
{
Date d1 = new Date(new DateTime(2001, 2, 3, 4, 5, 6, 7).AddTicks(8));
Date d2 = new Date(2001, 2, 3);
Assert.AreEqual(d1, d2);
Assert.IsTrue(d1.Equals(d2));
}
示例2: Comparison
public void Comparison()
{
var firstDate = new Date(2011, 1, 1);
var sameAsFirstDate = new Date(2011, 1, 1);
var laterDate = new Date(2011, 1, 2);
Expect(firstDate < laterDate);
Expect(laterDate < firstDate, Is.False);
Expect(firstDate > laterDate, Is.False);
Expect(laterDate > firstDate);
Expect(firstDate <= laterDate);
Expect(laterDate <= firstDate, Is.False);
Expect(firstDate >= laterDate, Is.False);
Expect(laterDate >= firstDate);
Expect(firstDate <= sameAsFirstDate);
Expect(firstDate >= sameAsFirstDate);
Expect(firstDate < sameAsFirstDate, Is.False);
Expect(firstDate > sameAsFirstDate, Is.False);
Expect(firstDate, Is.EqualTo(sameAsFirstDate));
Expect(firstDate.Equals(sameAsFirstDate));
}
示例3: ObjectEquality
public void ObjectEquality()
{
Date d1 = new Date();
d1.Value = System.DateTime.Now.ToUniversalTime().ToString();
d1.Count = 42;
Date d2 = new Date (d1.Value, d1.Count);
Assert.IsTrue (d1 == d2, "(d1 == d2) should be true");
Assert.IsFalse (d1 != d2, "(d1 != d2) should be false");
Assert.IsTrue (d1.Equals (d2), "d1.Equals(d2) should be true");
Assert.IsTrue (d1.ReferenceEquals (d1), "d1.ReferenceEquals(d1) should be true");
Assert.IsFalse (d1.ReferenceEquals (d2), "d1.ReferenceEquals(d2) should be false");
}
示例4: op_Equals_DateTime
public void op_Equals_DateTime(bool expected,
int day)
{
var obj = new Date(2012, 5, 30);
var other = new DateTime(2012, 5, day, 12, 0, 0);
Assert.Equal(expected, obj.Equals(other));
}