TimeZoneInfo.TransitionTime.Equals 方法

定义

确定两个 TimeZoneInfo.TransitionTime 对象是否具有相同的值。

重载

Equals(Object)

确定是否一个对象具有与当前 TimeZoneInfo.TransitionTime 对象相同的值。

Equals(TimeZoneInfo+TransitionTime)

确定当前 TimeZoneInfo.TransitionTime 对象是否具有与第二个 TimeZoneInfo.TransitionTime 对象相同的值。

Equals(Object)

确定是否一个对象具有与当前 TimeZoneInfo.TransitionTime 对象相同的值。

public:
 override bool Equals(System::Object ^ obj);
public override bool Equals (object? obj);
public override bool Equals (object obj);
override this.Equals : obj -> bool
Public Overrides Function Equals (obj As Object) As Boolean

参数

obj
Object

将与当前的 TimeZoneInfo.TransitionTime 对象进行比较的对象。

返回

Boolean

如果两个对象相等,则为 true;否则为 false

示例

下面的示例演示了对方法的 Equals 调用。

TimeZoneInfo.TransitionTime tt1 = TimeZoneInfo.TransitionTime.CreateFixedDateRule(new DateTime(1, 1, 1, 02, 00, 00), 11, 03);
TimeZoneInfo.TransitionTime tt2 = TimeZoneInfo.TransitionTime.CreateFixedDateRule(new DateTime(1, 1, 1, 02, 00, 00), 11, 03);
TimeZoneInfo.TransitionTime tt3 = TimeZoneInfo.TransitionTime.CreateFloatingDateRule(new DateTime(1, 1, 1, 02, 00, 00), 10, 05, DayOfWeek.Sunday);
TimeZoneInfo tz = TimeZoneInfo.Local;
Console.WriteLine(tt1.Equals(tz));         // Returns False (overload with argument of type Object)
Console.WriteLine(tt1.Equals(tt1));        // Returns True (an object always equals itself)
Console.WriteLine(tt1.Equals(tt2));        // Returns True (identical property values)
Console.WriteLine(tt1.Equals(tt3));        // Returns False (different property values)
let tt1 = TimeZoneInfo.TransitionTime.CreateFixedDateRule(DateTime(1, 1, 1, 02, 00, 00), 11, 03)
let tt2 = TimeZoneInfo.TransitionTime.CreateFixedDateRule(DateTime(1, 1, 1, 02, 00, 00), 11, 03)
let tt3 = TimeZoneInfo.TransitionTime.CreateFloatingDateRule(DateTime(1, 1, 1, 02, 00, 00), 10, 05, DayOfWeek.Sunday)
let tz = TimeZoneInfo.Local
printfn $"{tt1.Equals tz}"         // Returns False (overload with argument of type Object)
printfn $"{tt1.Equals tt1}"        // Returns True (an object always equals itself)
printfn $"{tt1.Equals tt2}"        // Returns True (identical property values)
printfn $"{tt1.Equals tt3}"        // Returns False (different property values)
Dim tt1 As TimeZoneInfo.TransitionTime = TimeZoneInfo.TransitionTime.CreateFixedDateRule(#02:00:00AM#, 11, 03)
Dim tt2 As TimeZoneInfo.TransitionTime = TimeZoneInfo.TransitionTime.CreateFixedDateRule(#02:00:00AM#, 11, 03)
Dim tt3 As TimeZoneInfo.TransitionTime = TimeZoneInfo.TransitionTime.CreateFloatingDateRule(#02:00:00AM#, 10, 05, DayOfWeek.Sunday)
Dim tz As TimeZoneInfo = TimeZoneInfo.Local
Console.WriteLine(tt1.Equals(tz))          ' Returns False (overload with argument of type Object)
Console.WriteLine(tt1.Equals(tt1))         ' Returns True (an object always equals itself)
Console.WriteLine(tt1.Equals(tt2))         ' Returns True (identical property values)
Console.WriteLine(tt1.Equals(tt3))         ' Returns False (different property values)

注解

相等性的定义如下:参数 obj 必须是对象 TimeZoneInfo.TransitionTime ,并且必须具有与当前 TimeZoneInfo.TransitionTime 对象相同的属性值。

适用于

Equals(TimeZoneInfo+TransitionTime)

确定当前 TimeZoneInfo.TransitionTime 对象是否具有与第二个 TimeZoneInfo.TransitionTime 对象相同的值。

public:
 virtual bool Equals(TimeZoneInfo::TransitionTime other);
public bool Equals (TimeZoneInfo.TransitionTime other);
override this.Equals : TimeZoneInfo.TransitionTime -> bool
Public Function Equals (other As TimeZoneInfo.TransitionTime) As Boolean

参数

other
TimeZoneInfo.TransitionTime

要与当前实例进行比较的对象。

返回

Boolean

如果两个对象具有相同的属性值,则为 true;否则为 false

实现

示例

下面的示例演示了对方法的 Equals 调用。

TimeZoneInfo.TransitionTime tt1 = TimeZoneInfo.TransitionTime.CreateFixedDateRule(new DateTime(1, 1, 1, 02, 00, 00), 11, 03);
TimeZoneInfo.TransitionTime tt2 = TimeZoneInfo.TransitionTime.CreateFixedDateRule(new DateTime(1, 1, 1, 02, 00, 00), 11, 03);
TimeZoneInfo.TransitionTime tt3 = TimeZoneInfo.TransitionTime.CreateFloatingDateRule(new DateTime(1, 1, 1, 02, 00, 00), 10, 05, DayOfWeek.Sunday);
Console.WriteLine(tt1.Equals(tt1));        // Returns True (an object always equals itself)
Console.WriteLine(tt1.Equals(tt2));        // Returns True (identical property values)
Console.WriteLine(tt1.Equals(tt3));        // Returns False (different property values)
let tt1 = TimeZoneInfo.TransitionTime.CreateFixedDateRule(DateTime(1, 1, 1, 02, 00, 00), 11, 03)
let tt2 = TimeZoneInfo.TransitionTime.CreateFixedDateRule(DateTime(1, 1, 1, 02, 00, 00), 11, 03)
let tt3 = TimeZoneInfo.TransitionTime.CreateFloatingDateRule(DateTime(1, 1, 1, 02, 00, 00), 10, 05, DayOfWeek.Sunday)
printfn $"{tt1.Equals tt1}"        // Returns True (an object always equals itself)
printfn $"{tt1.Equals tt2}"        // Returns True (identical property values)
printfn $"{tt1.Equals tt3}"        // Returns False (different property values)
Dim tt1 As TimeZoneInfo.TransitionTime = TimeZoneInfo.TransitionTime.CreateFixedDateRule(#02:00:00AM#, 11, 03)
Dim tt2 As TimeZoneInfo.TransitionTime = TimeZoneInfo.TransitionTime.CreateFixedDateRule(#02:00:00AM#, 11, 03)
Dim tt3 As TimeZoneInfo.TransitionTime = TimeZoneInfo.TransitionTime.CreateFloatingDateRule(#02:00:00AM#, 10, 05, DayOfWeek.Sunday)
Console.WriteLine(tt1.Equals(tt1))         ' Returns True (an object always equals itself)
Console.WriteLine(tt1.Equals(tt2))         ' Returns True (identical property values)
Console.WriteLine(tt1.Equals(tt3))         ' Returns False (different property values)

注解

若要确定这两 TimeZoneInfo.TransitionTime 个对象是否相等,此方法执行按属性比较的属性。 仅当当前对象和other对象对每个TimeZoneInfo.TransitionTime对象的六个属性值具有相同的值时,该方法才会返回trueTimeZoneInfo.TransitionTime

适用于