Converting double to string with N decimals, dot as decimal separator, and no thousand separator

后端 未结 7 2110
礼貌的吻别
礼貌的吻别 2020-12-28 11:43

I need to convert a decimal to a string with N decimals (two or four) and NO thousand separator:

\'XXXXXXX (dot) DDDDD\'

The problem with CultureInfo.I

7条回答
  •  遥遥无期
    2020-12-28 12:25

    I think you could have used:
    value.ToString("F"+NumberOfDecimals)

    value = 10,502
    value.ToString("F2") //10,50
    value = 10,5 
    value.ToString("F2") //10,50
    

    Here is a detailed description of Numeric Format Strings

提交回复
热议问题