C# ComboBox Selected Text To Multiple Strings
I have a combobox that has the entries of a full na开发者_开发知识库me, 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?
You can just use string.split
string str = "John Adams";
string[] names= str.Split(' '); //names[0]="John" names[1]="Adams"
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(' ');
////////
精彩评论