DateTimeOffset.EqualsExact(DateTimeOffset) Yöntem
Tanım
Önemli
Bazı bilgiler ürünün ön sürümüyle ilgilidir ve sürüm öncesinde önemli değişiklikler yapılmış olabilir. Burada verilen bilgilerle ilgili olarak Microsoft açık veya zımni hiçbir garanti vermez.
Geçerli DateTimeOffset nesnenin aynı saati temsil edip etmediğini ve belirtilen DateTimeOffset nesneyle aynı uzaklığı olup olmadığını belirler.
public:
bool EqualsExact(DateTimeOffset other);
public bool EqualsExact(DateTimeOffset other);
member this.EqualsExact : DateTimeOffset -> bool
Public Function EqualsExact (other As DateTimeOffset) As Boolean
Parametreler
- other
- DateTimeOffset
Geçerli DateTimeOffset nesneyle karşılaştıracak nesne.
Döndürülenler
true geçerli DateTimeOffset nesneyse ve other aynı tarih ve saat değerine ve aynı Offset değere sahipse; değilse, false.
Örnekler
Aşağıdaki örnek, benzer EqualsExact nesneleri karşılaştırmak için yönteminin DateTimeOffset kullanımını gösterir.
DateTimeOffset instanceTime = new DateTimeOffset(2007, 10, 31, 0, 0, 0,
DateTimeOffset.Now.Offset);
DateTimeOffset otherTime = instanceTime;
Console.WriteLine("{0} = {1}: {2}",
instanceTime, otherTime,
instanceTime.EqualsExact(otherTime));
otherTime = new DateTimeOffset(instanceTime.DateTime,
TimeSpan.FromHours(instanceTime.Offset.Hours + 1));
Console.WriteLine("{0} = {1}: {2}",
instanceTime, otherTime,
instanceTime.EqualsExact(otherTime));
otherTime = new DateTimeOffset(instanceTime.DateTime + TimeSpan.FromHours(1),
TimeSpan.FromHours(instanceTime.Offset.Hours + 1));
Console.WriteLine("{0} = {1}: {2}",
instanceTime, otherTime,
instanceTime.EqualsExact(otherTime));
// The example produces the following output:
// 10/31/2007 12:00:00 AM -07:00 = 10/31/2007 12:00:00 AM -07:00: True
// 10/31/2007 12:00:00 AM -07:00 = 10/31/2007 12:00:00 AM -06:00: False
// 10/31/2007 12:00:00 AM -07:00 = 10/31/2007 1:00:00 AM -06:00: False
let instanceTime = DateTimeOffset(2007, 10, 31, 0, 0, 0, DateTimeOffset.Now.Offset)
let otherTime = instanceTime
printfn $"{instanceTime} = {otherTime}: {instanceTime.EqualsExact otherTime}"
let otherTime = DateTimeOffset(instanceTime.DateTime, TimeSpan.FromHours(instanceTime.Offset.Hours + 1 |> float))
printfn $"{instanceTime} = {otherTime}: {instanceTime.EqualsExact otherTime}"
let otherTime = DateTimeOffset(instanceTime.DateTime + TimeSpan.FromHours 1, TimeSpan.FromHours(instanceTime.Offset.Hours + 1 |> float))
printfn $"{instanceTime} = {otherTime}: {instanceTime.EqualsExact otherTime}"
// The example produces the following output:
// 10/31/2007 12:00:00 AM -07:00 = 10/31/2007 12:00:00 AM -07:00: True
// 10/31/2007 12:00:00 AM -07:00 = 10/31/2007 12:00:00 AM -06:00: False
// 10/31/2007 12:00:00 AM -07:00 = 10/31/2007 1:00:00 AM -06:00: False
Dim instanceTime As New DateTimeOffset(#10/31/2007 12:00AM#, _
DateTimeOffset.Now.Offset)
Dim otherTime As DateTimeOffset = instanceTime
Console.WriteLine("{0} = {1}: {2}", _
instanceTime, otherTime, _
instanceTime.EqualsExact(otherTime))
otherTime = New DateTimeOffset(instanceTime.DateTime, _
TimeSpan.FromHours(instanceTime.Offset.Hours + 1))
Console.WriteLine("{0} = {1}: {2}", _
instanceTime, otherTime, _
instanceTime.EqualsExact(otherTime))
otherTime = New DateTimeOffset(instanceTime.DateTime + TimeSpan.FromHours(1), _
TimeSpan.FromHours(instanceTime.Offset.Hours + 1))
Console.WriteLine("{0} = {1}: {2}", _
instanceTime, otherTime, _
instanceTime.EqualsExact(otherTime))
' The example produces the following output:
' 10/31/2007 12:00:00 AM -07:00 = 10/31/2007 12:00:00 AM -07:00: True
' 10/31/2007 12:00:00 AM -07:00 = 10/31/2007 12:00:00 AM -06:00: False
' 10/31/2007 12:00:00 AM -07:00 = 10/31/2007 1:00:00 AM -06:00: False
Açıklamalar
Birden çok saat dilimi tek bir uzaklığı paylaştığından, değerinin true dönüş değeri geçerli ve nesnenin other aynı saat dilimindeki saatleri temsil ettiğini garanti etmez.
yönteminden EqualsExact farklı olarak, yönteminin aşırı yüklemeleri yalnızca iki Equals değerin DateTimeOffset zaman içinde tek bir noktayı temsil edip etmediğini belirler. İki değerin aynı tarih ve saatin yanı sıra aynı uzaklığı olduğunu göstermez.