I haven't had enough coffee this morning yet and for some reason this doesn't look right.
I have two objects that I need to convert into one byte array. One object is already a byte array, and the other is a Guid.
Given that sockId is a Guid and commandData is a byte array, is this valid?
//finally we need to add the socket's Guid to the commandData so that the interpreter
//knows where to send the response and also remove the data length that was originally
//contained in the byte array at position 0.
int TotalBytes = dataLength - 4 + 16;
int i = 0;
byte[] NewCommandData = new byte[TotalBytes];
while (i <= TotalBytes)
{
//add the Guid byte array
while (i < 16)
{
NewCommandData[i] = sockId.ToByteArray()[i];
i++;
}
//add the commandData byte array
NewCommandData[i] = commandData[i - 12];
i++;
}
or is there a better (preferrably faster, more elegant) way of doing this?