string value;
System.Globalization.NumberStyles
style;
System.Globalization.CultureInfo
culture;
float number;
value = "1.345,978";
style =
System.Globalization.NumberStyles.AllowDecimalPoint |
System.Globalization.NumberStyles.AllowThousands;
culture =
System.Globalization.CultureInfo.CreateSpecificCulture("es-ES");
if (Single.TryParse(value, style, culture, out number))
Console.WriteLine("Converted '{0}' to {1}.", value, number);
else
Console.WriteLine("Unable to convert '{0}'.", value);
value = "1345,978";
if (Single.TryParse(value, style, culture, out number))
Console.WriteLine("Converted '{0}' to {1}.", value, number);
else
Console.WriteLine("Unable to convert '{0}'.", value);
var convertBack = number.ToString(culture);
No comments:
Post a Comment