Computer >> Máy Tính >  >> Lập trình >> C#

Lấy mã băm cho phiên bản Thập phân hiện tại trong C #

Để lấy mã băm cho phiên bản Thập phân hiện tại, mã như sau -

Ví dụ

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 -

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