Q:

C# program to get a sorted collection of all the time zones (TimeZoneInfo.GetSystemTimeZones() Method)

belongs to collection: C# TimeZoneInfo Class Programs

0

Syntax:

    ReadOnlyCollection<TimeZoneInfo> TimeZoneInfo.GetSystemTimeZones();

Parameter(s):

  • None

Return value:

This method returns a sorted collection of all the time zones.

Exception(s):

  • System.OutOfMemoryException
  • System.Security.SecurityException
  •  

All Answers

need an explanation for this answer? contact us directly to get an explanation for this answer

Program:

The source code to get a sorted collection of all the time zones is given below. The given program is compiled and executed successfully.

using System;
using System.Globalization;
using System.Collections.ObjectModel;

class TimeZoneInfoDemo
{
    //Entry point of Program
    static public void Main()
    {
        //Create a collection to get list of time zone.
        ReadOnlyCollection<TimeZoneInfo> listOfTimeZones;

        listOfTimeZones = TimeZoneInfo.GetSystemTimeZones();

        Console.WriteLine("\nList of Time Zone:");
        foreach (TimeZoneInfo time_zone in listOfTimeZones)
        {
            Console.WriteLine("{0, 39}", time_zone.DaylightName);
        }
    }
}

Output:

List of Time Zone:
                 Dateline Daylight Time
                    Samoa Daylight Time
                 Hawaiian Daylight Time
                  Alaskan Daylight Time
                  Pacific Daylight Time
         Pacific Daylight Time (Mexico)
              US Mountain Daylight Time
        Mountain Daylight Time (Mexico)
                 Mountain Daylight Time
          Central America Daylight Time
                  Central Daylight Time
         Central Daylight Time (Mexico)
           Canada Central Daylight Time
               SA Pacific Daylight Time
                  Eastern Daylight Time
               US Eastern Daylight Time
                Venezuela Daylight Time
                 Paraguay Daylight Time
                 Atlantic Daylight Time
               SA Western Daylight Time
        Central Brazilian Daylight Time
               Pacific SA Daylight Time
             Newfoundland Daylight Time
         E. South America Daylight Time
                Argentina Daylight Time
               SA Eastern Daylight Time
                Greenland Daylight Time
               Montevideo Daylight Time
             Mid-Atlantic Daylight Time
                   Azores Daylight Time
               Cape Verde Daylight Time
                  Morocco Daylight Time
             Coordinated Universal Time
                      GMT Daylight Time
                Greenwich Daylight Time
                W. Europe Daylight Time
           Central Europe Daylight Time
                  Romance Daylight Time
         Central European Daylight Time
        W. Central Africa Daylight Time
                   Jordan Daylight Time
                      GTB Daylight Time
              Middle East Daylight Time
                    Egypt Daylight Time
             South Africa Daylight Time
                      FLE Daylight Time
                Jerusalem Daylight Time
                E. Europe Daylight Time
                  Namibia Daylight Time
                   Arabic Daylight Time
                     Arab Daylight Time
                  Russian Daylight Time
                E. Africa Daylight Time
                 Georgian Daylight Time
                     Iran Daylight Time
                  Arabian Daylight Time
               Azerbaijan Daylight Time
                Mauritius Daylight Time
                 Caucasus Daylight Time
              Afghanistan Daylight Time
             Ekaterinburg Daylight Time
                 Pakistan Daylight Time
                West Asia Daylight Time
                    India Daylight Time
                Sri Lanka Daylight Time
                    Nepal Daylight Time
          N. Central Asia Daylight Time
             Central Asia Daylight Time
                  Myanmar Daylight Time
                  SE Asia Daylight Time
               North Asia Daylight Time
                    China Daylight Time
          North Asia East Daylight Time
          Malay Peninsula Daylight Time
             W. Australia Daylight Time
                   Taipei Daylight Time
                    Tokyo Daylight Time
                    Korea Daylight Time
                  Yakutsk Daylight Time
           Cen. Australia Daylight Time
              AUS Central Daylight Time
             E. Australia Daylight Time
              AUS Eastern Daylight Time
             West Pacific Daylight Time
                 Tasmania Daylight Time
              Vladivostok Daylight Time
          Central Pacific Daylight Time
              New Zealand Daylight Time
                     Fiji Daylight Time
                Kamchatka Daylight Time
                    Tonga Daylight Time
Press any key to continue . . .

 

need an explanation for this answer? contact us directly to get an explanation for this answer

total answers (1)

C# TimeZoneInfo Class Programs

This question belongs to these collections

Similar questions


need a help?


find thousands of online teachers now
C# program to calculate the offset between the tim... >>
<< C# program to get the hash code of the time zone (...