If someone passes me an ArraySegment<byte> foo
and this segment points into a larger buffer, what's the idiomatic way to copy this segment into a fresh new byte[]
?
I tried accessing at foo.Array
but this seems to point to the beginning of the larger buffer, not the beginning of the segment.
e.g. the larger buffer could be "blahfoobar" and the ArraySegment points to "foo". I want to get a byte[]
with just "foo".
I'm sure it's dead simple, but coming from C++, I can't figure the lingo used in c#.