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

Popular posts from this blog

php - Displaying JSON data posts for blog using just the post id -

docusignapi - Documents restrictions within a package -

javascript - angular.forEach loop with $http.get -