Dollar ($) sign and commas in thousands for a number with String.Format()

This question already has an answer here:

  • Currency format for display 6 answers

  • You can use the overload of ToString() which takes an IFormatProvider as argument and specify that the number is currency.

    var value = 5620000;
    value.ToString("C", new System.Globalization.CultureInfo("en-US"))
    

    EDIT

    As @Uwe Keim pointed out you can also use the String.Format() overload that does this:

    String.Format(new System.Globalization.CultureInfo("en-US"), "{0:C}", 5620000)
    
    链接地址: http://www.djcxy.com/p/50550.html

    上一篇: 如何执行机器代码(学习程序集)

    下一篇: 美元($)符号和逗号以数字为单位,String.Format()