Format a double value like currency but without the currency sign (C#)

后端 未结 9 826
無奈伤痛
無奈伤痛 2020-12-25 10:07

I feed a textbox a string value showing me a balance that need to be formatted like this:

###,###,###,##0.00

I could use the value.ToString

相关标签:
9条回答
  • 2020-12-25 10:29

    string result=string.Format("{0:N2}", value); //For result like ### ### ##.##

    0 讨论(0)
  • 2020-12-25 10:29
    CultureInfo cultureInfo = new CultureInfo("en-US");
    cultureInfo.NumberFormat.CurrencySymbol = "Rs.";
    
    Thread.CurrentThread.CurrentCulture = cultureInfo;
    decimal devimalValue = 3.45M;
    this.Text = devimalValue.ToString("C2"); //Rs.3.45
    
    0 讨论(0)
  • 2020-12-25 10:35
    string forDisplay = currentBalance.ToString("N2");
    
    0 讨论(0)
提交回复
热议问题