Use ToString() to format integers : Integer format : Data Type C# Examples


C# Examples » Data Type » Integer format »

 

Use ToString() to format integers









    
using  System;  
  
class  MainClass  {  
    public  static  void  Main()  {  
        int  x  =  21;  

        string  str  =  x.ToString("X");  
        Console.WriteLine(str);  
  
        str  =  x.ToString("D12");  
        Console.WriteLine(str);  
  
    }  
}
    
   
  
   



Output

15
000000000021


HTML code for linking to this page:

Follow Navioo On Twitter

C# Examples

 Navioo Data Type
» Integer format