Phương thức Decimal.GetHashCode () trong C # được sử dụng để trả về mã băm cho phiên bản hiện tại.
Cú pháp
Sau đây là cú pháp -
public override int GetHashCode ();
Ví dụ
Bây giờ chúng ta hãy xem một ví dụ để triển khai phương thức 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()) );
}
} Đầu ra
Điều này sẽ tạo ra kết quả sau -
Decimal Value = 135269.38193 HashCode = 1328665595
Ví dụ
Bây giờ chúng ta hãy xem một ví dụ khác để triển khai phương thức 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()) );
}
} Đầu ra
Điều này sẽ tạo ra kết quả sau -
Decimal Value = 79228162514264337593543950335 HashCode = 1173356544