0

Hi want to convert in C# a double 1123$ to 1.123,00 (one thousand and two decimal).

How can I do that?

thanks

ezechiele2517
  • 375
  • 1
  • 5
  • 19
  • Are these $ values, ie you want to print dollars, but with mainland european separators. If I was doing a mixture like that, I'd bve looking at constructing a NumberFormatInfo. See this for further details, it's about negatives, but the concept holds. http://stackoverflow.com/questions/11014878/how-to-use-numberformatinfo-to-remove-parenthesis-for-negative-values – Tony Hopkinson Feb 15 '14 at 11:30

3 Answers3

1

Try:

var text = money.ToString("N0",
    System.Globalization.CultureInfo.GetCultureInfo("de"));
Kostadin
  • 405
  • 3
  • 14
1

You might want to use this

YourDecimal.ToString("N",new CultureInfo("nl-NL")) // this will result in 1.000,00 for example
YourDecimal.ToString("N",new CultureInfo("en-US")) // this will result in 1,000.00 for example

Or you could set the culture in Web.Config if you're using ASP.NET.

You can also pick any other culture if that matches the dot and comma delimiter ofcourse. These are just examples.

Rob
  • 3,556
  • 2
  • 34
  • 53
1
Double x=1123.0;    
x.ToString("N",new CultureInfo("nl-NL"))
AnOldSoul
  • 4,017
  • 12
  • 57
  • 118