Created
January 17, 2015 15:29
-
-
Save timgaunt/8e0a78af164d74a61599 to your computer and use it in GitHub Desktop.
Split First and Last name from Name
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var names = name.Trim().Split(new[] { ' ' }, 2); | |
string firstName; | |
string lastName; | |
if (names.Length == 1) | |
{ | |
firstName = String.Empty; | |
lastName = names[0]; | |
} | |
else | |
{ | |
firstName = names[0]; | |
lastName = names[1]; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment