您可以在C#中以各种方式定义一个数字,
1F // a float with the value 1
1L // a long with the value 1
1D // a double with the value 1
Run Code Online (Sandbox Code Playgroud)
我个人正在寻找哪种方式short,但是为了让问题更好地为人们提供参考,你可以应用的数字文字的所有其他后期修复是什么?
Sco*_*man 23
Type Suffix .NET Framework Type
-------------------------------------------------------------------------------------
decimal M or m System.Decimal
double D or d System.Double
float F or f System.Single
int [1] System.Int32
long L or l System.Int64
Run Code Online (Sandbox Code Playgroud)
[1]当整数文字没有后缀时,它的类型是这些类型中的第一个,其值可以表示为:int,uint,long,ulong.
当整数文字仅指定U或u后缀时,其类型是这些类型中的第一个,其值可以被重新表示:uint,ulong.
当整数文字仅指定L或l后缀时,其类型是这些类型中的第一个,其值可以被重新设置:long,ulong.
当一个整数文字同时指定U或U和L或l后缀,其类型是第一这些类型的,其中它的值可被represnted的:ULONG.
为了钱:
decimal mon = 1m;
Run Code Online (Sandbox Code Playgroud)
对于输出:
string curr = String.Format("{0:C}", mon); //output $1.00
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
15200 次 |
| 最近记录: |