Home » C#

C# | DateTime.GetHashCode() Method with Example

DateTime.GetHashCode() Method: Here, we are going to learn about the GetHashCode() method of DateTime class with example in C#.
Submitted by IncludeHelp, on October 22, 2019

DateTime.GetHashCode() Method

DateTime.GetHashCode() method is used get the 32-bit signed integer hash code of DateTime class object.

Syntax:

    int DateTime.GetHashCode();

Parameter(s):

  • It does not accept any parameter.

Return value:

The return type of this method is int, it returns 32-bit integer hash code.

Example to demonstrate example of DateTime.GetHashCode() method

using System;

namespace ConsoleApplication1
{
    class Program
    {
        static void Main(string[] args)
        {
            int res = 0;

            //Create object of datetime class
            DateTime dt1 = new DateTime(2019,1,1,10,10,10);

            //Get hashcode of DateTime object.
            res = dt1.GetHashCode();

            //Print hashcode of DateTime object.
            Console.WriteLine("HashCode of dt1 is: " + res);

            Console.WriteLine();  
        }
    }
}

Output

HasCode of dt1 is: 1193378513
ADVERTISEMENT
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.