I would like to return all elements but the last element. I looked at maybe using the Skip() method but got confused. Can anyone help me out please?
Thank you
I would like to return all elements but the last element. I looked at maybe using the Skip() method but got confused. Can anyone help me out please?
Thank you
You can use Enumerable.Take()
for this:
var results = theArray.Take(theArray.Length - 1);
This will let you enumerate all elements except the last in the array.
You can do the following:
var array = ...;
var arrayExceptLasElement = array.Take(array.Length-1);
Hope that helps!