Hello,
I'm currently working with byte arrays to hold data transmitted over the network, and i'm looking for a way to copy a section of that byte array and return it from a function result.
I know I can create a temporary array and call the CopyTo function to copy the data in that array, but I was wondering this this piece of code below with LinQ would do the same.
- RawContent is a property that returns a byte[] array
- Size is a long that gives the range of the data to copy
- 64 is the offset in Rawcontent to copy from.
Would this call return a byte array with the values from RawContent[64]-> RawContent[Size] ?
EDIT: changed the range setting.
I'm currently working with byte arrays to hold data transmitted over the network, and i'm looking for a way to copy a section of that byte array and return it from a function result.
I know I can create a temporary array and call the CopyTo function to copy the data in that array, but I was wondering this this piece of code below with LinQ would do the same.
Code:
return (from m in Enumerable.Range(0, Size) select RawContent[64 + m]);
- Size is a long that gives the range of the data to copy
- 64 is the offset in Rawcontent to copy from.
Would this call return a byte array with the values from RawContent[64]-> RawContent[Size] ?
EDIT: changed the range setting.
Comment