Propose: Locale-independent decimal seperator

T

Teis Draiby

Does this already exist?

Something like "\£" that would appear like a "," or "." dependent on the
current locale settings.


Examples:
string stringValue = "1000\£54"
Console.WriteLine(stringValue);
// Outputs "1000,54" or "1000.54" dependent on locale settings:

double doubleValue = Convert.ToDouble(stringValue);
// Will always convert correctly and not ignore
// seperator if it doesn't match locale settings

float floatValue = 34.65F
string stringFromFloat = floatValue.ToString();
// stringFromFloat will now contain "34\£65"
Console.WriteLine(stringFromFloat);
// ...but still output "34,65" or "34.65"



....
Anyway, how can I determine which is the current decimal seperator? In a
text field I want to automatically correct the typed seperator if the user
has typed the wrong one according to the locale (I assume that the user
doesn't want to type digit grouping symbols).

Thank you very much, any answer is appreciated

regards, Teis
 
R

ru

Does this already exist?

Something like "\£" that would appear like a "," or "." dependent on the
current locale settings.


Examples:
string stringValue = "1000\£54"
Console.WriteLine(stringValue);
// Outputs "1000,54" or "1000.54" dependent on locale settings:

double doubleValue = Convert.ToDouble(stringValue);
// Will always convert correctly and not ignore
// seperator if it doesn't match locale settings

float floatValue = 34.65F
string stringFromFloat = floatValue.ToString();
// stringFromFloat will now contain "34\£65"
Console.WriteLine(stringFromFloat);
// ...but still output "34,65" or "34.65"



...
Anyway, how can I determine which is the current decimal seperator? In a
text field I want to automatically correct the typed seperator if the user
has typed the wrong one according to the locale (I assume that the user
doesn't want to type digit grouping symbols).

Thank you very much, any answer is appreciated

regards, Teis

You can find out like so:
Dim strDecimal As String =
CultureInfo.CurrentCulture.NumberFormat.NumberDecimalSeparator

HTH,
ru
 
T

Teis Draiby

Thank you! That was exactly what I was looking for.
In .NET everything is right at your hand. I knew it!

Regards, teis.
 
Top