string - Prefix '0' to the int variable which less than '10', How? -


Is there any easy way to insert '0' before any variable variable?

Like:

  int i = 2; // output i = some method (i); // output: i = 02  

If you mean "concatenate" You define some methods () as follows:

  string someMethod (int i) {return string.format ("{0: d2}", i); }  

Defines the number of characters in the "2" output in the string format.


Comments