views:

286

answers:

2

I have a combobox that has the entries of a full name, eg: John Smith, Mark Tall, etc.

I have written the following:

string FullName = StudentSelectStudentComboBox.Text;

This gets "John Smith" as the string 'FullName'. Is it possible to break down 'FullName' string into 2 strings; FirstName and LastName?

+1  A: 

You can just use string.split

string str = "John Adams";
string[] names=   str.Split(' ');    //names[0]="John"   names[1]="Adams"
Ngu Soon Hui
A: 

This answer is similar to Ngu Soon Hui but with a twist: If you want to get fancy you can try:

///////////////

//Names[0] = first name, Name[1] = last name

string[] Names = StudentSelectStudentComboBox.Text.Split(' ');

////////

Phil