Reputation: 472
Lets suppose this in C#.
double d = 5.555455;
string s = d.ToString();
Console.WriteLine(s);
The output is
5.555455
In my case my regional configuration is for "." as decimal separator. The problem is that the computer's regional configuration sometimes is "," which makes the output to be:
5,555455
What I do need is to make sure that the number will be ALWAYS be converted to a string using "." as decimal and no "," as thousand separator.
How can I achieve this?
Upvotes: 1
Views: 95
Reputation: 726539
You need to use the invariant culture:
double d = 5.555455;
string s = d.ToString(CultureInfo.InvariantCulture);
Console.WriteLine(s);
Among other things, this forces the dot .
as the decimal separator.
Upvotes: 5