I would like to change decimal point to another character in C#. I have a double
variable value
double value;
and when I use the command:
Console.WriteLine(value.ToString()); // output is 1,25
I know I can do this:
Console.WriteLine(value.ToString(
CultureInfo.CreateSpecificCulture("en-GB"))); // output is 1.25
but I don't like it very much because it's very long and I need it quite often in my program.
Is there a shorter version for setting "decimal point" really as point and not comma as is in my culture is usual?
Some shortcut is to create a NumberFormatInfo class, set its NumberDecimalSeparator property to "." and use the class as parameter to ToString() method whenever u need it.
using System.Globalization;
NumberFormatInfo nfi = new NumberFormatInfo();
nfi.NumberDecimalSeparator = ".";
value.ToString(nfi);