C# 中的 Decimal.ToString() 方法用於將此實例的數值轉換為其等效的字符串表示形式。
用法
以下是語法 -
public override string ToString ();
示例
現在讓我們看一個實現 Decimal.ToString() 方法的例子 -
using System;
public class Demo{
public static void Main(){
decimal d = 3444.787m;
string str = d.ToString();
Console.WriteLine("String = "+str);
}
}
輸出
這將產生以下輸出 -
String = 3444.787
示例
讓我們看另一個例子 -
using System;
public class Demo{
public static void Main(){
decimal d = 100;
string str = d.ToString();
Console.WriteLine("String = "+str);
}
}
輸出
這將產生以下輸出 -
String = 100
相關用法
- C# Decimal.ToSingle()用法及代碼示例
- C# Decimal.ToSByte()用法及代碼示例
- C# Decimal.ToDouble()用法及代碼示例
- C# Decimal.ToOACurrency()用法及代碼示例
- C# Decimal.ToInt64()用法及代碼示例
- C# Decimal.ToInt16()用法及代碼示例
- C# Decimal.ToInt32()用法及代碼示例
- C# Decimal.ToUInt64()用法及代碼示例
- C# Decimal.ToUInt16()用法及代碼示例
- C# Decimal.ToUInt32()用法及代碼示例
- C# Decimal.ToByte()用法及代碼示例
- C# Decimal.Truncate()用法及代碼示例
- C# Decimal.FromOACurrency()用法及代碼示例
- C# Decimal.GetBits()用法及代碼示例
- C# Decimal.Remainder()用法及代碼示例
- C# Decimal.GetTypeCode用法及代碼示例
- C# Decimal.Negate()用法及代碼示例
- C# Decimal.GetHashCode()用法及代碼示例
- C# Decimal.Subtract()用法及代碼示例
- C# Decimal.CompareTo()用法及代碼示例
注:本文由純淨天空篩選整理自AmitDiwan大神的英文原創作品 Decimal.ToString() Method in C#。非經特殊聲明,原始代碼版權歸原作者所有,本譯文未經允許或授權,請勿轉載或複製。