ezechiele2517
ezechiele2517

Reputation: 375

C# how to convert a double to string with decimal and thousand

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

How can I do that?

thanks

Upvotes: 0

Views: 883

Answers (3)

AnOldSoul
AnOldSoul

Reputation: 4197

Double x=1123.0;    
x.ToString("N",new CultureInfo("nl-NL"))

Upvotes: 1

Rob
Rob

Reputation: 3574

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.

Upvotes: 1

Kostadin
Kostadin

Reputation: 405

Try:

var text = money.ToString("N0",
    System.Globalization.CultureInfo.GetCultureInfo("de"));

Upvotes: 1

Related Questions