且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

如何在C#中获取除最后一个元素之外的所有数组元素

更新时间:2023-11-10 07:55:52

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

无需反转和跳过.只需比数组中的元素少一个.

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

如果您真的希望元素按相反的顺序排列,您可以在末尾添加 .Reverse().

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