I know that in C # we can always get the submatrix of a given array using the method Array.Copy(). However, this will consume more memory and processing time, which is not necessary in a read-only situation. For example, I write a program with a heavy load, which very often exchanges messages with other nodes in the cluster. The first 20 bytes of each message are the message header, and the remaining bytes make up the message body. Therefore, I will divide the received raw message into an array of header bytes and an array of body bytes in order to process them separately. However, this will obviously consume dual memory and extra time. In C, we can easily use a pointer and assign an offset to it to access different parts of the array. For example, in C, if we havechar a[] = "ABCDEFGHIJKLMN", we can declare char* ptr = a + 3to represent an array DEFGHIJKLMN.
Is there a way to accomplish this in C #?
source
share