Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

C# question

Posted on 2011-03-25
4
Medium Priority
?
309 Views
Last Modified: 2012-05-11
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
Comment
Question by:SubbuUSA
  • 2
4 Comments
 
LVL 18

Expert Comment

by:Dennis Aries
ID: 35215395
Where do you want to leave the part 'De' of 'Andy De Souza'? With the first name, or with the last?
0
 
LVL 7

Accepted Solution

by:
dimaj earned 1000 total points
ID: 35215401
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
 

Author Comment

by:SubbuUSA
ID: 35215436
I want 'Andy De ' to be a first name
0
 

Author Closing Comment

by:SubbuUSA
ID: 35216532
Thanks
0

Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Article by: Najam
Having new technologies does not mean they will completely replace old components.  Recently I had to create WCF that will be called by VB6 component.  Here I will describe what steps one should follow while doing so, please feel free to post any qu…
Entity Framework is a powerful tool to help you interact with the DataBase but still doesn't help much when we have a Stored Procedure that returns more than one resultset. The solution takes some of out-of-the-box thinking; read on!
This Micro Tutorial will teach you how to add a cinematic look to any film or video out there. There are very few simple steps that you will follow to do so. This will be demonstrated using Adobe Premiere Pro CS6.
Screencast - Getting to Know the Pipeline

916 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question