string to int, double?
-
string s = "5"; int i = int.Parse(s);
-
alma wrote: How can i convert a string into an int or double in C#? You may also want to check out the Convert Class[^] and it's members[^] -Nick Parker
-
you might also want to put it inside a try block also in case it cant be converted. the Char class has an isNumber to determine if thier all numbers. I'm sure theres a better way of doing it though Maybe even better would be to extend the Double if its not final I'm not an expert yet, but I play one at work. Yeah and here too.
-
hi, there is a simple way of doing this. suppose you have a string "strg" and an int "ix". try { ix = Convert.ToInt32(strg); } catch(Exception ex) // needed in case string cannot be converted. { // do something with the exception } i think you can similarly convert to double as well.