Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
DateTime.GetHashCode() Method in C#
The DateTime.GetHashCode() method in C# is used to returns the hash code for this instance. This return value is a 32-bit signed integer hash code.
Syntax
Following is the syntax −
public override int GetHashCode ();
Example
Let us now see an example to implement the DateTime.GetHashCode() method −
using System;
public class Demo {
public static void Main() {
DateTime d = new DateTime(2019, 11, 10, 7, 20, 45);
int res = d.GetHashCode();
Console.WriteLine("HashCode for date {0} = {1}", d, res);
}
}
Output
This will produce the following output −
HashCode for date 11/10/2019 7:20:45 AM = -2002476754
Example
Let us now see another example to implement the DateTime.GetHashCode() method −
using System;
public class Demo {
public static void Main() {
DateTime d = DateTime.Now;
int res = d.GetHashCode();
Console.WriteLine("HashCode for date {0} = {1}", d, res);
}
}
Output
This will produce the following output −
HashCode for date 10/16/2019 7:03:37 AM = -16205546
Advertisements