This is a common situation for copying a range from an array. C # supports this operation in various ways, for example, using Array.Copy, but also using a combination of Linq Skip and Take.
Starting with .NET 4.0, do the Skip and Run operations carry out significant overhead, or do they recognize (at compile time or at run time) that their target is an array?
To clarify: I mean: a) the time taken to complete the initial bytes and b) the Skip-Take-ToArray combination, which does not suffer from side effects. For example, it new byte[10000].Skip(9999).Take(1).ToArray()can be optimized in this way and will (for large n) be noticeably faster.
source
share