Decimal parse for currency : Decimal parse : Data Type C# Examples


C# Examples » Data Type » Decimal parse »

 

Decimal parse for currency









    
using  System;
using  System.Collections.Generic;
using  System.Globalization;
using  System.Text;
using  System.Text.RegularExpressions;
using  System.Reflection;

public  class  MainClass{

      public  static  void  Main(){
                string[]  money  =  new  string[]  {  "$0.99",  "$0,99",  "$1000000.00",  "$10.25",  "$90,000.00",  "$90.000,00",  "$1,000,000.00",  "$1,000000.00"  };
                foreach  (string  m  in  money)
                {
                        try
                        {
                                Decimal.Parse(m,  NumberStyles.Currency);
                                Console.WriteLine("!{0}:  True",  m);
                        }
                        catch  (FormatException)
                        {
                                Console.WriteLine("!{0}:  False",  m);
                        }

                }
      }
}
    
   
  
   



Output

!$0.99: True
!$0,99: True
!$1000000.00: True
!$10.25: True
!$90,000.00: True
!$90.000,00: False
!$1,000,000.00: True
!$1,000000.00: True


HTML code for linking to this page:

Follow Navioo On Twitter

C# Examples

 Navioo Data Type
» Decimal parse