Computer >> คอมพิวเตอร์ >  >> การเขียนโปรแกรม >> C#

Decimal.ToUInt32() วิธีการใน C #


Decimal.ToUInt32() วิธีการใน C # ใช้เพื่อแปลงค่าของทศนิยมที่ระบุให้เป็นจำนวนเต็ม 32 บิตที่ไม่ได้ลงนามที่เทียบเท่า

ไวยากรณ์

ต่อไปนี้เป็นไวยากรณ์ -

public static uint ToUInt32 (decimal val);

ด้านบน Val คือตัวเลขทศนิยมที่จะแปลง

ตัวอย่าง

ให้เราดูตัวอย่างการใช้งาน Decimal.ToUInt32() วิธีการ -

using System;
public class Demo {
   public static void Main(){
      Decimal val = 0.001m;
      Console.WriteLine("Decimal value = "+val);
      uint res = Decimal.ToUInt32(val);
      Console.WriteLine("32-bit unsigned integer = "+res);
   }
}

ผลลัพธ์

สิ่งนี้จะสร้างผลลัพธ์ต่อไปนี้ -

Decimal value = 0.001
32-bit unsigned integer = 0

ตัวอย่าง

ให้เราดูตัวอย่างอื่นเพื่อใช้วิธีการ Decimal.ToUInt32() -

using System;
public class Demo {
   public static void Main(){
      Decimal val = 67.487m;
      Console.WriteLine("Decimal value = "+val);
      uint res = Decimal.ToUInt32(val);
      Console.WriteLine("32-bit unsigned integer = "+res);
   }
}

ผลลัพธ์

สิ่งนี้จะสร้างผลลัพธ์ต่อไปนี้ -

Decimal value = 67.487
32-bit unsigned integer = 67