if(rows.Any()) //prevent IndexOutOfRangeException for empty list
{
rows.RemoveAt(rows.Count - 1);
}
using System;
using System.Linq;
class RemoveLastElement {
static void Main() {
int[] a = { 2, 3, 4, 5, 6};
int[] result = a.SkipLast(1).ToArray();
Console.WriteLine(String.Join(",", result));
}
}