How can I convert an int var into a string var in C#?
+3
A:
The ToString method of any object is supposed to return a string representation of that object.
int var1 = 2;
string var2 = var1.ToString();
VoodooChild
2010-06-21 03:21:46
+8
A:
string s = i.ToString();
string s = Convert.ToString(i);
string s = string.Format("{0}", i);
string s = string.Empty + i;
string s = new StringBuilder().Append(i).ToString();
Xavier Poinas
2010-06-21 03:24:30
variety is the spice of life.
Jesse C. Slicer
2010-06-21 03:30:16
@variety, hope you are not married with those opinions :p
VoodooChild
2010-06-21 03:37:02
+1 for completeness.
Craig Trader
2010-06-21 03:53:02