Parsing numbers with culture invariant parsing : Number Parse : I18N Internationalization C# Examples


C# Examples » I18N Internationalization » Number Parse »

 

Parsing numbers with culture invariant parsing









    
using  System;
using  System.Collections;
using  System.Collections.Generic;
using  System.IO;
using  System.Reflection;
using  System.Resources;
using  System.Text;
using  System.Threading;
using  System.Globalization;

public  class  MainClass
{
        public  static  void  Main()
        {
                CultureInfo  current  =  CultureInfo.CurrentCulture;
                string  numberString  =  "33,223.510";

                        try
                        {
                                double  number  =  double.Parse(numberString,  CultureInfo.InvariantCulture);
                                Console.WriteLine("Parsed!  {0}",  number);
                        }
                        catch  (Exception  e)
                        {
                                Console.WriteLine("Caught  exception:  {0}",  e.ToString());
                        }
        }
}
    
   
  
   



Output

Parsed! 33223.51


HTML code for linking to this page:

Follow Navioo On Twitter

C# Examples

 Navioo I18N Internationalization
» Number Parse