how to take all array elements except last element in C#

后端 未结 6 834
滥情空心
滥情空心 2020-12-14 14:50

I have a string array like this.

string[] queries with data more than one string.

I want to skip the last string from the element and take the r

6条回答
  •  别那么骄傲
    2020-12-14 15:17

    var remStrings = queries.Take(queries.Length - 1);
    

    No need to Reverse and Skip. Just take one less element than there are in the array.

    If you really wanted the elements in the reverse order, you could tack on a .Reverse() to the end.

提交回复
热议问题