Trim array size

Hello, I can’t seem to figure out how to simply trim a array down to a specified size after I have sorted it.
In my example I have a ton of files in a folder which I first add to a array, I then sort them and after that I want to just keep a set amount of the oldest files in my array for use.
I know I can transfer them to another array quite easily but I’m wondering if there’s a way to use the already existing one and just “cut” off the tail of the array no matter how many that is, the only set amount should be elements remaining.

Hi,

How about Take method as the following?

tempFiles = TempFiles.Take(100).ToArray()

Regards,

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.