C# TimeZoneInfo Equals(TimeZoneInfo)

Description

TimeZoneInfo Equals(TimeZoneInfo) determines whether the current TimeZoneInfo object and another TimeZoneInfo object are equal.

Syntax

TimeZoneInfo.Equals(TimeZoneInfo) has the following syntax.


public bool Equals(
  TimeZoneInfo other
)

Parameters

TimeZoneInfo.Equals(TimeZoneInfo) has the following parameters.

  • other - A second object to compare with the current object.

Returns

TimeZoneInfo.Equals(TimeZoneInfo) method returns true if the two TimeZoneInfo objects are equal; otherwise, false.

Example

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


/*from  w ww.  j  av a 2 s  .  c  o  m*/
using System;
public class MainClass{
  public static void Main(String[] argv){  
    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));
  }
}
    

The code above generates the following result.





















Home »
  C# Tutorial »
    System »




Array
BitConverter
Boolean
Byte
Char
Console
ConsoleKeyInfo
Convert
DateTime
DateTimeOffset
Decimal
Double
Enum
Environment
Exception
Guid
Int16
Int32
Int64
Math
OperatingSystem
Random
SByte
Single
String
StringComparer
TimeSpan
TimeZone
TimeZoneInfo
Tuple
Tuple
Tuple
Type
UInt16
UInt32
UInt64
Uri
Version