andyw27
asked on
Splitting String into Int
Hi,
I have a simple string 35,1
Which is separated by a comma.
Taking this string I need to output two int’s
X = 35
Y = 1
Is this possible please?
I have a simple string 35,1
Which is separated by a comma.
Taking this string I need to output two int’s
X = 35
Y = 1
Is this possible please?
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
You can also use one-liners:
string v = "35,1";
int x = Convert.ToInt32(v.Split(', ')[0]);
int y = Convert.ToInt32(v.Split(', ')[1]);
/gustav
string v = "35,1";
int x = Convert.ToInt32(v.Split(',
int y = Convert.ToInt32(v.Split(',
/gustav
string str = "35,1";
string [ ] str1 = str.split(",");
int n1 = convert.toInt(str1[0].toSt
int n2 = convert.toInt(str1[1].toSt
try this I hope it's working...