Check if current object and another TimeZoneInfo object have the same adjustment rules in CSharp
Description
The following code shows how to check if current object and another TimeZoneInfo object have the same adjustment rules.
Example
//from www. j a v a 2 s. c o m
using System.Collections.ObjectModel;
using System;
public class MainClass{
public static void Main(String[] argv){
ReadOnlyCollection<TimeZoneInfo> timeZones = TimeZoneInfo.GetSystemTimeZones();
TimeZoneInfo[] timeZoneArray = new TimeZoneInfo[timeZones.Count];
timeZones.CopyTo(timeZoneArray, 0);
for (int ctr = timeZoneArray.GetUpperBound(0); ctr >= 1; ctr--)
{
TimeZoneInfo thisTimeZone = timeZoneArray[ctr];
for (int compareCtr = 0; compareCtr <= ctr - 1; compareCtr++)
{
if (thisTimeZone.HasSameRules(timeZoneArray[compareCtr]))
{
Console.WriteLine("{0} has the same rules as {1}",
thisTimeZone.StandardName,
timeZoneArray[compareCtr].StandardName);
}
}
}
}
}
The code above generates the following result.