c# - String.join array from last element -
i have scenario getting comma separated string lastname, firstname. have convert firstname lastname.
my code below:
public static void main(string [] args) { var str = "lastname, firstname": var strarr = str.split(','); array. reverse(strarr); var output = string.join(" ", strarr); }
is there better way this, in 1 line or using linq?
yes there reverse extension method ienumerables:
var output = string.join(" ",str.split(',').reverse());
Comments
Post a Comment