Array.Copy: strange exception while concatenating two byte arrays
- by robob
In a application of mine that is developed in C# I have the following code:
byte[] resb = new byte[Buffer.ByteLength(blockAr) + Buffer.ByteLength(previous)];
Array.Copy(blockAr, 0, resb,0, blockAr.Length);
Array.Copy(previous, 0, resb, blockAr.Length, previous.Length);
It's a very simple code to concatenate two byte arrays.
The problem is that in some particular situation that I don't know I have that exception:
ArgumentOutOfRangeException: sourceIndex is less than the lower bound of the first dimension of sourceArray.
I cannot see any of strange in my code and I am not able to reproduce the exception.
Could anyone help me to identify the problem?
thanks