Skip to content

Instantly share code, notes, and snippets.

@timgaunt
Created January 17, 2015 15:29
Show Gist options
  • Save timgaunt/8e0a78af164d74a61599 to your computer and use it in GitHub Desktop.
Save timgaunt/8e0a78af164d74a61599 to your computer and use it in GitHub Desktop.
Split First and Last name from Name
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