Question Overlapping byte arrays

jdlessl

New member
Joined
Aug 23, 2018
Messages
1
Programming Experience
10+
I would like to create a byte array that actually points to a particular spot on another byte array. Got a deserializer that needs the payload from a message (i.e., without the header) as a byte array, and I don't want to have to Marshal.Copy every single byte over to a new array every single time. Can that even be done in C#? I can create an IntPtr that addresses the correct starting point no problem, but I can't then create a byte[] from that.
 
What you're talking about is not a byte array in C#. In C/C++, a byte array is simply a pointer to a byte. In C#, it's a instance of the Array class, so quite different. If you want to be able to use pointers in C# like you do in C/C++ then you can (for the most part) with the 'unsafe' keyword. That's where you should start your search.
 

Latest posts

Back
Top Bottom