C# program to get the hash code of the time zone (TimeZoneInfo.GetHashCode() Method)

C# TimeZoneInfo.GetHashCode() Method: Here, we are going to learn how to get the hash code of the time zone in C#.Net?
Submitted by Nidhi, on May 19, 2021

The GetHashCode() method of TimeZoneInfo class is a static method and used to get the hash code value of time zones.

Syntax:

    int TimeZoneInfo.GetHashCode();

Parameter(s):

  • None

Return value:

This method returns an integer value that represents the hash code of the timezone.

Program:

The source code to get the hash code of the time zone 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 object of date and time format.
        DateTimeFormatInfo datTimeFormat;

        //Create collection for timezones
        ReadOnlyCollection<TimeZoneInfo> ListOftimeZones;

        datTimeFormat = CultureInfo.CurrentCulture.DateTimeFormat;
        ListOftimeZones = TimeZoneInfo.GetSystemTimeZones();

        Console.WriteLine("HashCodes: ");
        foreach (TimeZoneInfo time_zone in ListOftimeZones)
        {
            Console.WriteLine("\t"+time_zone.GetHashCode());
        }
    }
}

Output:

HashCodes:
        -514555984
        -758128916
        -1369885288
        1929871915
        -20620119
        1966587549
        -1011079097
        -1549238612
        867061357
        -2030645691
        -1472553907
        -774670651
        398800922
        -51503002
        1575136615
        -1920434229
        -1759550415
        781531414
        1688170723
        277435212
        780897488
        672784620
        -1290608544
        1061339055
        1409949984
        849007863
        -1010907336
        -91072651
        1857440091
        1289301972
        524845130
        -985979243
        -884914970
        1243702734
        -2134877238
        417657061
        -1072506847
        1951788994
        587654972
        1596262695
        1796499939
        1141185203
        -152181505
        137358981
        -1896308101
        -1437804775
        203046616
        567328507
        390533655
        2030831431
        -2011598098
        -581402749
        -72981115
        1022731794
        2018412928
        271408839
        457374418
        -1818159890
        1602929463
        858250651
        -74019787
        -1714669205
        153346398
        -270438407
        -2049351688
        296234527
        -1887523373
        199744320
        -851594192
        1782768786
        1141291926
        779965156
        -1853844139
        -981867726
        -963623640
        -1152086148
        2058205788
        1859384373
        -846996468
        -409381159
        -1265531735
        -873538331
        13992051
        1703400787
        556097360
        -1534558847
        -1503639322
        2053458808
        -1078326823
        -1759089867
        1773130869
Press any key to continue . . .

C# TimeZoneInfo Class Programs »


ADVERTISEMENT
ADVERTISEMENT




Comments and Discussions!




Languages: » C » C++ » C++ STL » Java » Data Structure » C#.Net » Android » Kotlin » SQL
Web Technologies: » PHP » Python » JavaScript » CSS » Ajax » Node.js » Web programming/HTML
Solved programs: » C » C++ » DS » Java » C#
Aptitude que. & ans.: » C » C++ » Java » DBMS
Interview que. & ans.: » C » Embedded C » Java » SEO » HR
CS Subjects: » CS Basics » O.S. » Networks » DBMS » Embedded Systems » Cloud Computing
» Machine learning » CS Organizations » Linux » DOS
More: » Articles » Puzzles » News/Updates

© https://www.includehelp.com some rights reserved.