在 C# 中將十進位制轉換為 Int64 (long)
使用 Convert.ToInt64() 方法在 C# 中將 Decimal 轉換為 Int64 (long)。
假設我們有一個十進位制變數。
decimal d = 310.23m;
現在使用 Convert.ToInt64() 方法,將它轉換為 Int64。
long res; res = Convert.ToInt64(d);
讓我們看另一個示例 −
示例
using System;
class Demo {
static void Main() {
decimal d = 190.66m;
long res;
res = Convert.ToInt64(d);
Console.WriteLine("Converted Decimal '{0}' to Int64 value {1}", d, res);
}
}輸出
Converted Decimal '190.66' to Int64 value 191
廣告
資料結構
網路
RDBMS
作業系統
Java
iOS
HTML
CSS
Android
Python
C 程式設計
C++
C#
MongoDB
MySQL
Javascript
PHP