C# program to determine whether two TimeZoneInfo objects are equal (TimeZoneInfo.Equals() Method)
using System;
using System.Globalization;
using System.Collections.ObjectModel;
class TimeZoneInfoDemo
{
//Entry point of Program
static public void Main()
{
TimeZoneInfo localTimeZone;
TimeZoneInfo timeZone1;
TimeZoneInfo timeZone2;
localTimeZone = TimeZoneInfo.Local;
timeZone1 = TimeZoneInfo.FindSystemTimeZoneById("Central Standard Time");
timeZone2 = TimeZoneInfo.FindSystemTimeZoneById("Eastern Standard Time");
if (localTimeZone.Equals(timeZone1))
Console.WriteLine("Both are equal");
else
Console.WriteLine("Both are not equal");
if (localTimeZone.Equals(timeZone2))
Console.WriteLine("Both are equal");
else
Console.WriteLine("Both are not equal");
}
}
Both are not equal
Both are not equal
Press any key to continue . . .
Table of Contents