I am allocating an array that is intentionally bigger than the result of BitConverter.GetBytes. My goal is to leave the last byte empty so that I can prevent this number from being seen as the two's compliment and have tempPosBytes2[
When I run BitConverter.GetBytes my array tempPosBytes2
seems to shrink.
uint positiveNumber = 4293967296;
byte[] tempPosBytes2 = new byte[tempPosBytes.Length + 1]; // four bytes plus one
tempPosBytes2 = BitConverter.GetBytes(positiveNumber); // tempPositiveBytes2 is now 4 bytes!!
Question
What is going on under the covers, and how can I leave the trailing byte without copying the array?
I need this to work with BigInteger(byte[]) as in the following:
BigInteger positiveBigIntBAD2 = new BigInteger(tempPosBytes2); // Invalid