If you want a bitwise copy, i.e. get 4 bytes out of one int, then use Buffer.BlockCopy
:
byte[] result = new byte[intArray.Length * sizeof(int)];
Buffer.BlockCopy(intArray, 0, result, 0, result.Length);
Don't use Array.Copy
, because it will try to convert and not just copy. See the remarks on the MSDN page for more info.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…