Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

C# question

Posted on 2011-03-25
4
Medium Priority
?
302 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

On Demand Webinar: Networking for the Cloud Era

Did you know SD-WANs can improve network connectivity? Check out this webinar to learn how an SD-WAN simplified, one-click tool can help you migrate and manage data in the cloud.

Question has a verified solution.

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

It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…
This article aims to explain the working of CircularLogArchiver. This tool was designed to solve the buildup of log file in cases where systems do not support circular logging or where circular logging is not enabled
In this video, Percona Solutions Engineer Barrett Chambers discusses some of the basic syntax differences between MySQL and MongoDB. To learn more check out our webinar on MongoDB administration for MySQL DBA: https://www.percona.com/resources/we…
Want to learn how to record your desktop screen without having to use an outside camera. Click on this video and learn how to use the cool google extension called "Screencastify"! Step 1: Open a new google tab Step 2: Go to the left hand upper corn…

722 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