Прочетете на английски Редактиране

Споделяне чрез


TimeZoneInfo.TransitionTime.Equals Method

Definition

Determines whether two TimeZoneInfo.TransitionTime objects have identical values.

Overloads

Equals(Object)

Determines whether an object has identical values to the current TimeZoneInfo.TransitionTime object.

Equals(TimeZoneInfo+TransitionTime)

Determines whether the current TimeZoneInfo.TransitionTime object has identical values to a second TimeZoneInfo.TransitionTime object.

Equals(Object)

Source:
TimeZoneInfo.TransitionTime.cs
Source:
TimeZoneInfo.TransitionTime.cs
Source:
TimeZoneInfo.TransitionTime.cs

Determines whether an object has identical values to the current TimeZoneInfo.TransitionTime object.

C#
public override bool Equals(object? obj);
C#
public override bool Equals(object obj);

Parameters

obj
Object

An object to compare with the current TimeZoneInfo.TransitionTime object.

Returns

true if the two objects are equal; otherwise, false.

Examples

The following example illustrates calls to the Equals method.

C#
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)

Remarks

Equality is defined as follows: The obj parameter must be a TimeZoneInfo.TransitionTime object and must have property values identical to the current TimeZoneInfo.TransitionTime object.

Applies to

.NET 10 и други версии
Продукт Версии
.NET Core 2.0, Core 2.1, Core 2.2, Core 3.0, Core 3.1, 5, 6, 7, 8, 9, 10
.NET Framework 3.5, 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8, 4.8.1
.NET Standard 2.0, 2.1

Equals(TimeZoneInfo+TransitionTime)

Source:
TimeZoneInfo.TransitionTime.cs
Source:
TimeZoneInfo.TransitionTime.cs
Source:
TimeZoneInfo.TransitionTime.cs

Determines whether the current TimeZoneInfo.TransitionTime object has identical values to a second TimeZoneInfo.TransitionTime object.

C#
public bool Equals(TimeZoneInfo.TransitionTime other);

Parameters

other
TimeZoneInfo.TransitionTime

An object to compare to the current instance.

Returns

true if the two objects have identical property values; otherwise, false.

Implements

Examples

The following example illustrates calls to the Equals method.

C#
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)

Remarks

To determine whether the two TimeZoneInfo.TransitionTime objects are equal, this method performs a property-by-property comparison. The method returns true only if the current TimeZoneInfo.TransitionTime object and the other object have identical values for each of the TimeZoneInfo.TransitionTime object's six property values.

Applies to

.NET 10 и други версии
Продукт Версии
.NET Core 2.0, Core 2.1, Core 2.2, Core 3.0, Core 3.1, 5, 6, 7, 8, 9, 10
.NET Framework 3.5, 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8, 4.8.1
.NET Standard 2.0, 2.1