Index outbound array issue when splitting the string

Hi All,

I need to split string first name and last name the value is “AUDIT-TEL” I am splitting string based on space and hyphen but i am getting index out bound array.

Firstname = strBn1Value.Split({" “,”-"},stringSplitOptions.RemoveEmptyEntries)(1).Trim
Lastname=strBn1Value.Split({" "},stringSplitOptions.RemoveEmptyEntries)(2).Trim

For last name value iam getting index out bound array issue. Please some one helpme.

Regards,
Hima

@thima If the First Name is “AUDIT” and the Last Name is “TEL” that you want it to be separated, then the following expression should give you the needed output :

FirstName = Split(strBn1Value,"-")(0).ToString
LastName = Split(strBn1Value,"-")(1).ToString

If this is not the output that you expected, Please explain more as to why you are also splitting with a Space

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.