本文整理汇总了C#中LocalDate.Equals方法的典型用法代码示例。如果您正苦于以下问题:C# LocalDate.Equals方法的具体用法?C# LocalDate.Equals怎么用?C# LocalDate.Equals使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类LocalDate
的用法示例。
在下文中一共展示了LocalDate.Equals方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Equals_DifferentCalendars
public void Equals_DifferentCalendars()
{
CalendarSystem calendar = CalendarSystem.Julian;
LocalDate date1 = new LocalDate(2011, 1, 2, calendar);
LocalDate date2 = new LocalDate(2011, 1, 2, CalendarSystem.Iso);
Assert.AreNotEqual(date1, date2);
Assert.AreNotEqual(date1.GetHashCode(), date2.GetHashCode());
Assert.IsFalse(date1 == date2);
Assert.IsTrue(date1 != date2);
Assert.IsFalse(date1.Equals(date2)); // IEquatable implementation
}
示例2: Equals_EqualValues
public void Equals_EqualValues()
{
CalendarSystem calendar = CalendarSystem.GetJulianCalendar(4);
LocalDate date1 = new LocalDate(2011, 1, 2, calendar);
LocalDate date2 = new LocalDate(2011, 1, 2, calendar);
Assert.AreEqual(date1, date2);
Assert.AreEqual(date1.GetHashCode(), date2.GetHashCode());
Assert.IsTrue(date1 == date2);
Assert.IsFalse(date1 != date2);
Assert.IsTrue(date1.Equals(date2)); // IEquatable implementation
}
示例3: Equals_DifferentToOtherType
public void Equals_DifferentToOtherType()
{
LocalDate date = new LocalDate(2011, 1, 2);
Assert.IsFalse(date.Equals(Instant.FromTicksSinceUnixEpoch(0)));
}
示例4: Equals_DifferentToNull
public void Equals_DifferentToNull()
{
LocalDate date = new LocalDate(2011, 1, 2);
Assert.IsFalse(date.Equals(null));
}
示例5: Equals_DifferentToOtherType
public void Equals_DifferentToOtherType()
{
LocalDate date = new LocalDate(2011, 1, 2);
Assert.IsFalse(date.Equals(new Instant(0)));
}