Subset of Array in C#

LINQ is your friend. 🙂

var newArray = oldArray.Skip(1).Take(oldArray.Length - 2).ToArray();

Somewhat less efficient than manually creating the array and iterating over it of course, but far simple…

The slightly lengithier method that uses Array.Copy is the following.

var newArray = new int[oldArray.Count - 2];
Array.Copy(oldArray, 1, newArray, 0, newArray.Length);

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)