DateTime.GetHashCode() Method: Here, we will find out about the GetHashCode() technique for DateTime class with example in C#.
DateTime.GetHashCode() Method
DateTime.GetHashCode() strategy is utilized get the 32-piece marked integer hash code of DateTime class object.
Syntax:
int DateTime.GetHashCode();
Parameter(s):
It doesn’t acknowledge any parameter.
Return value:
The arrival kind of this strategy is int, it returns 32-piece integer hash code.
Example to exhibit example of DateTime.GetHashCode() strategy
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