C#String格式化货币格式 [英] C# String Formatting currency formate
本文介绍了C#String格式化货币格式的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
要显示带有相关货币符号和相应小数位数的数字,我们使用货币字符C或c,如:
Console.WriteLine({0: C},1.2);
输出中出现的数字1.2如下:$ 1.20。
我的问题是{0:C中0表示的是什么}}
解决方案
1.20。
我的问题是0表示{0:C} ??
它引用了参数中的变量(零)索引。
Console.WriteLine({0:C} {1:C} {0:C},1.2,1.5);
将输出:
1.2 1.5 1.2
祝你好运!
To display a number with its associated currency symbol and the appropriate number of decimal places we use the currency character "C" or "c", like:
Console.WriteLine("{0:C}", 1.2");
The number 1.2 appears in the output like this: $1.20.
my question is what does "0" indicates in {0:C}??
解决方案
1.20.
my question is what does "0" indicates in {0:C}??
It referers to the variable (zero-)index in params.
Console.WriteLine("{0:C} {1:C} {0:C}", 1.2, 1.5);
will output:
1.2 1.5 1.2
Good luck!
这篇关于C#String格式化货币格式的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文