1
Array.Copy(sourceArray,targetArray,length);
Buffer.BlockCopy(sourceArray,startInSource,targetArray,startInTarget,Length);
變量是長度爲sourceArray.Length
或sourceArray.Length * sizeof(type)
?最後的Array.Copy&Buffer.BlockCopy
其中,type是sourceArray
中元素的類型,例如,當源數組是整數時int。
我在使用sourceArray.Length
時得到預期的結果,但我看到無數使用sourceArray.Length * sizeof(type)
的示例。我錯過了什麼?
你不用字節來做'sourceArray.Length * sizeof(type)'。這只是一個簡單的副本。當長度爲1時,它將複製1個4字節的整數。 –