Wednesday, March 13, 2013

Code snippet in VB.Net to split the Name eg. = "Mohammed Ghouse" to FirstName and LastName

If Not String.IsNullOrEmpty(element.Name) Then
    If element.Name.IndexOf(" ") = -1 Then
        eContact.FirstName = element.Name
    Else
        eContact.FirstName = element.Name.Substring(0, element.Name.IndexOf(" "))
        eContact.LastName = element.Name.Substring(element.Name.IndexOf(" ") + 1)
    End If
End If

No comments:

Post a Comment