C# TimeZoneInfo Equals(Object)

Description

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

Syntax

TimeZoneInfo.Equals(Object) has the following syntax.


public override bool Equals(
  Object obj
)

Parameters

TimeZoneInfo.Equals(Object) has the following parameters.

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

Returns

TimeZoneInfo.Equals(Object) method returns true if obj is a TimeZoneInfo object that is equal to the current instance; otherwise, false.

Example

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


using System;// w w  w .  j  a  va 2  s .  c o  m

public class Example
{
   public static void Main()
   {
      TimeZoneInfo thisTimeZone;
      object obj1, obj2;

      thisTimeZone = TimeZoneInfo.Local;
      obj1 = TimeZoneInfo.FindSystemTimeZoneById("Pacific Standard Time");
      obj2 = TimeZoneInfo.FindSystemTimeZoneById("Eastern Standard Time");
      Console.WriteLine(thisTimeZone.Equals(obj1));
      Console.WriteLine(thisTimeZone.Equals(obj2));
   }
}

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