Export (0) Print
Expand All
This topic has not yet been rated - Rate this topic

TimeZoneInfo.Equals Method (TimeZoneInfo)

Determines whether the current TimeZoneInfo object and another TimeZoneInfo object are equal.

Namespace:  System
Assembly:  mscorlib (in mscorlib.dll)
public bool Equals(
	TimeZoneInfo other
)

Parameters

other
Type: System.TimeZoneInfo
A second object to compare with the current object.

Return Value

Type: System.Boolean
true if the two TimeZoneInfo objects are equal; otherwise, false.

Implements

IEquatable<T>.Equals(T)

Equality is based on a comparison of values. Two TimeZoneInfo objects are considered to be equal under the following conditions:

  • The value of their Id property is the same.

  • They have the same adjustment rules.

TimeZoneInfo.Equals(TimeZoneInfo) returns the Boolean value that results from evaluating the following expression:

[C#]

other.Id == this.Id && HasSameRules(other);

[Visual Basic]

other.Id = me.Id AndAlso HasSameRules(other)

If the other parameter is an uninitialized TimeZoneInfo object, this method returns false.

The following example uses the Equals(TimeZoneInfo) method to determine whether the local time zone is Pacific Time or Eastern Time.


TimeZoneInfo thisTimeZone, zone1, zone2;

thisTimeZone = TimeZoneInfo.Local;
zone1 = TimeZoneInfo.FindSystemTimeZoneById("Pacific Standard Time");
zone2 = TimeZoneInfo.FindSystemTimeZoneById("Eastern Standard Time");
Console.WriteLine(thisTimeZone.Equals(zone1));
Console.WriteLine(thisTimeZone.Equals(zone2));


.NET Framework

Supported in: 4, 3.5

.NET Framework Client Profile

Supported in: 4, 3.5 SP1

Windows 7, Windows Vista SP1 or later, Windows XP SP3, Windows Server 2008 (Server Core not supported), Windows Server 2008 R2 (Server Core supported with SP1 or later), Windows Server 2003 SP2

The .NET Framework does not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.
Did you find this helpful?
(1500 characters remaining)
Thank you for your feedback

Community Additions

ADD
Show:
© 2014 Microsoft. All rights reserved.