Wednesday, August 16, 2006

C# String Formats

In asnwering a google groups post this evening I found this particulary helpful list of string formatters. The google groups post was asking how one can format an int of value 3 to a string "003". Two methods that immediately spring to mind are:

int i = 3;
string s1 = i.ToString ("000");
string s2 = String.Format ("{0:000}", i);

The google groups post can be found here.

0 Comments:

Post a Comment

<< Home