C# 中的 Decimal.GetHashCode() 方法用於返回當前實例的哈希碼。
用法
以下是語法 -
public override int GetHashCode ();
示例
現在讓我們看一個實現 Decimal.GetHashCode() 方法的例子 -
using System;
public class Demo {
public static void Main(){
Decimal val = 135269.38193M;
Console.WriteLine("Decimal Value = {0}", val);
Console.WriteLine("HashCode = {0}", (val.GetHashCode()) );
}
}
輸出
這將產生以下輸出 -
Decimal Value = 135269.38193 HashCode = 1328665595
示例
現在讓我們看另一個實現 Decimal.GetHashCode() 方法的例子 -
using System;
public class Demo {
public static void Main(){
Decimal val = Decimal.MaxValue;
Console.WriteLine("Decimal Value = {0}", val);
Console.WriteLine("HashCode = {0}", (val.GetHashCode()) );
}
}
輸出
這將產生以下輸出 -
Decimal Value = 79228162514264337593543950335 HashCode = 1173356544
相關用法
- C# Decimal.GetHashCode用法及代碼示例
- C# Decimal.GetBits()用法及代碼示例
- C# Decimal.GetTypeCode用法及代碼示例
- C# Decimal.GetTypeCode()用法及代碼示例
- C# Decimal.FromOACurrency()用法及代碼示例
- C# Decimal.ToDouble()用法及代碼示例
- C# Decimal.Remainder()用法及代碼示例
- C# Decimal.Truncate()用法及代碼示例
- C# Decimal.Negate()用法及代碼示例
- C# Decimal.ToOACurrency()用法及代碼示例
- C# Decimal.Subtract()用法及代碼示例
- C# Decimal.ToInt64()用法及代碼示例
- C# Decimal.CompareTo()用法及代碼示例
- C# Decimal.ToInt16()用法及代碼示例
- C# Decimal.ToInt32()用法及代碼示例
- C# Decimal.Round()用法及代碼示例
- C# Decimal.ToSingle()用法及代碼示例
- C# Decimal.ToString()用法及代碼示例
- C# Decimal.ToSByte()用法及代碼示例
- C# Decimal.ToUInt64()用法及代碼示例
注:本文由純淨天空篩選整理自AmitDiwan大神的英文原創作品 Decimal.GetHashCode() Method in C# with Examples。非經特殊聲明,原始代碼版權歸原作者所有,本譯文未經允許或授權,請勿轉載或複製。