I am trying to figure out if there is a way to do something in C #, which is pretty easy to do in C ++. In particular, if I have an array of data, I can create a pointer to this data for more convenient access to the subsection.
For example, if I have:
unsigned char buffer[1000];
and I determine that there is a line at positions from 102 to 110 inside this array, that I need to manipulate a lot, I can do this:
unsigned char *strPtr = &buffer[102]; char firstChar = strPtr[0];
This eliminates the need for me to add β102β to each array index in subsequent operations.
While I learn about the possibility of unsafe situations when you are doing something like this, I wonder if there is a moral equivalent in C # that would allow me to create a new link to a subset of an existing array.
Sort of:
byte [8] newArray = &buffer[102];
This example does not actually work, or I would not publish it, but I think it gets an idea of ββwhat I want to accomplish.
source share