Solved

C# question

Posted on 2011-03-25
4
289 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 250 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

[Webinar] Code, Load, and Grow

Managing multiple websites, servers, applications, and security on a daily basis? Join us for a webinar on May 25th to learn how to simplify administration and management of virtual hosts for IT admins, create a secure environment, and deploy code more effectively and frequently.

Question has a verified solution.

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

Suggested Solutions

Introduction Although it is an old technology, serial ports are still being used by many hardware manufacturers. If you develop applications in C#, Microsoft .NET framework has SerialPort class to communicate with the serial ports.  I needed to…
This article describes a simple method to resize a control at runtime.  It includes ready-to-use source code and a complete sample demonstration application.  We'll also talk about C# Extension Methods. Introduction In one of my applications…
Nobody understands Phishing better than an anti-spam company. That’s why we are providing Phishing Awareness Training to our customers. According to a report by Verizon, only 3% of targeted users report malicious emails to management. With compan…
In a recent question (https://www.experts-exchange.com/questions/29004105/Run-AutoHotkey-script-directly-from-Notepad.html) here at Experts Exchange, a member asked how to run an AutoHotkey script (.AHK) directly from Notepad++ (aka NPP). This video…

739 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