tags:

views:

176

answers:

6

How can I convert an int var into a string var in C#?

+12  A: 
string myString = myInt.ToString();
Anthony Pegram
+3  A: 
String s = num.ToString();
Evan Trimboli
+1  A: 
int num = 10;
string str = Convert.ToString(num);
Polaris
+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
+1  A: 

or:

string s = Convert.ToString(num);
Jesse C. Slicer
+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
variety is the spice of life.
Jesse C. Slicer
@variety, hope you are not married with those opinions :p
VoodooChild
+1 for completeness.
Craig Trader