Özgür ACAR Özgür ACAR - 2 months ago 7
C# Question

Split String and get desired part

Is there any way to get the portion of string after the last "_" forexample;

string1 = A_110_23_09_ABC

result1 = ABC




string2 = A_110_23_09_ABC_555

result2 = 555

Thanks.

Answer
var s = "A_110_23_09_ABC";
var result = s.Substring(s.LastIndexOf('_') + 1);
Comments