I found how to change the locale format in Java, but I want to use it in C#.
This is the (Java) line of code
String.format(Locale.US, "%f", floatValue)
I found how to change the locale format in Java, but I want to use it in C#.
This is the (Java) line of code
String.format(Locale.US, "%f", floatValue)
For Culture you can Use
CultureInfo en = new CultureInfo("en-US");
and for Formatting Float with Culture you can use
string.Format(new System.Globalization.CultureInfo("en-Us"), "{N2}", floatValue)
C# equivalent is (simple to string conversion)
String result = floatValue.ToString(new CultureInfo("en-US"));
Or (formatting)
String result = String.Format(new CultureInfo("en-US"), "{0}", floatValue);
By default in .Net if you use CultureInfo.InvariantCulture
it is associated with the English language en-US
or you can explicitly set CUltureInfo
float value = 16325.62015;
// Display value using the invariant culture.
Console.WriteLine( value.ToString(CultureInfo.InvariantCulture));
// Display value using the en-US culture.
Console.WriteLine(value.ToString(CultureInfo.CreateSpecificCulture("en-US")));