which variable can a string convert from to as I tried that using a double, also to System.Windows.Form.ListBox?
Thanks
which variable can a string convert from to as I tried that using a double, also to System.Windows.Form.ListBox?
Thanks
Know the answer? Post it — somebody with the same question will find it here.
Sign in to answer this question
It is the same account you read, post and publish with — and you will come straight back to this page.
AlanPosted Sep 7, 2007, 7:09 AM
You can convert strings containg numbers to actual numbers using the various Parse(), or TryParse(), methods. For example:
string s1 = "1234";
int i = int.Parse(s1); // i now contains the integer 1234
string s2 = "567.89";
double d = double.Parse(s2) // d now contains the floating point number 567.89
To convert numbers to strings you can either use the appropriate ToString() method or the Convert.ToString() method. For example:
int j = 43;
string s3 = j.ToString(); // s3 now contains the string "43"
string s4 = Convert.ToString(j); // s4 also contains the string "43"