[C#] Split TextBox Text
#2


// Splits the string in parts on every occurance of -
string[] splitted = listBox1.Text.Split('-');

string name = splitted[0].Trim();
int id = int.parse(splitted[1].Trim());

 

Ofcourse this will give a problem when there is a character with a - in the name

 

int id = int.parse(splitted[splitted.Length - 1].Trim());



Messages In This Thread
[No subject] - by Nikolee - 09-08-2012, 10:22 AM
[No subject] - by Wizatek - 09-08-2012, 10:25 AM
[No subject] - by HateMe - 09-08-2012, 11:53 AM

Forum Jump:


Users browsing this thread: 1 Guest(s)