Display positive, negative, and zero values differently : Double Format : Data Type C# Examples


C# Examples » Data Type » Double Format »

 

Display positive, negative, and zero values differently









    
using  System;    

class  MainClass  {    
    public  static  void  Main()  {    
        double  num  =  64354.2345;  

        Console.WriteLine("Default  format:  "  +  num);  

        Console.WriteLine("Display  positive,  negative,  "  +  
                                            "and  zero  values  differently.");  
        Console.WriteLine("{0:#.#;(#.##);0.00}",  num);  
        num  =  -num;  
        Console.WriteLine("{0:#.##;(#.##);0.00}",  num);  
        num  =  0.0;  
        Console.WriteLine("{0:#.##;(#.##);0.00}",  num);  
    }  
}
    
   
  
   



Output

Default format: 64354.2345
Display positive, negative, and zero values differently.
64354.2
(64354.23)
0.00


HTML code for linking to this page:

Follow Navioo On Twitter

C# Examples

 Navioo Data Type
» Double Format