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.
Answer a question in the forums and earn +20 SHARP for every answer.
See unanswered questions
DevSocialUpcoming · 3rd editionAI Agents ConferenceDec 1–3, 2026Live onlineFree to attend4days leftRegister
AlanRank #669 · 3.6K reputationPosted Sep 7, 2007, 3:09 AM EDT
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"