1

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?

2 Answers 2

1

You can just use string.split

string str = "John Adams";
string[] names=   str.Split(' ');    //names[0]="John"   names[1]="Adams"
Sign up to request clarification or add additional context in comments.

Comments

0

This answer is similar to the one above but with a twist: If you want to get fancy you can try:

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

//Names[0] = first name, Name1 = last name

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

////////

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.