要指定数字类型,请在C#中使用后缀。文字后缀是数字后缀。
例如,对于长型-
//长后缀 long val1 = 29345L;
对于双类型-
//双后缀 double val2 = 297.325D; Console.WriteLine(val2);
让我们看看更多示例-
using System.IO; using System; public class Program { public static void Main() { //长后缀 long val1 = 29345L; Console.WriteLine(val1); //十进制后缀 decimal val5 = 3245.5678M; Console.WriteLine(val5); //双后缀 double val2 = 297.325D; Console.WriteLine(val2); //浮点后缀 float val3 = 250.35F; Console.WriteLine(val3); //无符号后缀 uint val4 = 3456U; Console.WriteLine(val4); } }
输出结果
29345 3245.5678 297.325 250.35 3456