Mega Code Archive

 
Categories / C# Tutorial / Data Type
 

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);   } } myInt = 12345, myInt2 = 67890 myInt using 10:d = 12345 myInt using 10:x = 3039