• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 312
  • Last Modified:

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#
0
SubbuUSA
Asked:
SubbuUSA
  • 2
1 Solution
 
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
 
dimajCommented:
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
 
SubbuUSAAuthor Commented:
I want 'Andy De ' to be a first name
0
 
SubbuUSAAuthor Commented:
Thanks
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now