C# question

Friends,

I have string with Full Name like  (Mary Ann Smith) or (Andy De Souza).

I need to assign Smith or Souza as a last name and Mary Ann as a Firstname. My System does not have a middle name feature.

Would like to have a small snippet in c#
SubbuUSAAsked:
Who is Participating?
 
dimajConnect With a Mentor Commented:
do something like this:

string name = "Mary Ann Smith";
int pos = name.LastIndexOf(' ');
string fName = name.Substring(0, pos);
string lName = name.Substring(pos + 1);
0
 
Dennis AriesCEO @ Arkro ITCommented:
Where do you want to leave the part 'De' of 'Andy De Souza'? With the first name, or with the last?
0
 
SubbuUSAAuthor Commented:
I want 'Andy De ' to be a first name
0
 
SubbuUSAAuthor Commented:
Thanks
0
All Courses

From novice to tech pro — start learning today.