Formatting integers : Int format : Data Type C# Examples


C# Examples » Data Type » Int format »

 

Formatting integers









    
class  MainClass
{
    public  static  void  Main(){

        
        int  myInt  =  12345;
        int  myInt2  =  67890;
        System.Console.WriteLine("myInt  =  {0,  6},  myInt2  =  {1,  5}",  myInt,  myInt2);
        System.Console.WriteLine("myInt  using  10:d  =  {0,  10:d}",  myInt);
        System.Console.WriteLine("myInt  using  10:x  =  {0,  10:x2}",  myInt);

    }

}
    
   
  
   



Output

myInt =  12345, myInt2 = 67890
myInt using 10:d =      12345
myInt using 10:x =       3039


HTML code for linking to this page:

Follow Navioo On Twitter

C# Examples

 Navioo Data Type
» Int format