I am trying to figure out how to get this method to start at a index being ptr instead of overwriting from 0 - 8 bytes. Also if anyone knows how to make this work with Big / Little edian machines due to being networked, that would be awesome.
private byte[] buffer = new byte[30];
private int ptr = 0;
unsafe void GetBytes(ulong value)
{
fixed (byte* b = buffer) //start at buffer[ptr]
*((int*)b) = *(int*)&value;
ptr += 8;
}
I figured out how to make a pointer to the ptr via the following
private byte[] buffer = new byte[30];
private int ptr = 0;
unsafe void GetBytes(ulong value)
{
fixed (byte* b = &buffer[ptr]) //start at buffer[ptr]
*((int*)b) = *(int*)&value;
ptr += 8;
}