- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
Physics
Chemistry
Biology
Mathematics
English
Economics
Psychology
Social Studies
Fashion Studies
Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Double.GetHashCode() Method in C#
The Double.GetHashCode() method in C# is used to return the hash code for this instance.
Syntax
The syntax is as follows −
public override int GetHashCode ();
Example
Let us now see an example −
using System; public class Demo { public static void Main(){ double d1 = 150d; object ob1 = 1/2; Console.WriteLine("Double1 Value = "+d1); Console.WriteLine("Object Value = "+ob1); Console.WriteLine("Are both the values equal? = "+d1.Equals(ob1)); Console.WriteLine("HashCode of Double1 Value = {0}", d1.GetHashCode()); } }
Output
This will produce the following output −
Double1 Value = 150 Object Value = 0 Are both the values equal? = False HashCode of Double1 Value = 1080213504
Example
Let us now see another example −
using System; public class Demo { public static void Main(){ double d = 10d; Console.WriteLine("Double Value = "+d); Console.WriteLine("HashCode of Double Value = {0}", d.GetHashCode()); } }
Output
This will produce the following output −
Double Value = 10 HashCode of Double Value = 1076101120
Advertisements