Mega Code Archive

 
Categories / C# / Data Types
 

Parse string using as the thousands separator and as the decimal separator

using System; using System.Globalization; class MainClass {     public static void Main( )     {                           string value = "987 654,321";         NumberStyles style = NumberStyles.AllowDecimalPoint | NumberStyles.AllowThousands;         CultureInfo provider = new CultureInfo("fr-FR");         decimal number = Decimal.Parse(value, style, provider);           Console.WriteLine("'{0}' converted to {1}.", value, number);          } }