Buffer.BlockCopy VS Array.Copy VS ConstrainedCopy

Buffer.BlockCopy更高效,但是仅限于primitive类型

Array.ConstrainedCopy validates arrays before it copies them. The regular Array.Copy method will silently copy a byte array to an int array. The Array.ConstrainedCopy method instead throws an exception. This can improve reliability.

Copies a range of elements from an Array starting at the specified source index and pastes them to another Array starting at the specified destination index. Guarantees that all changes are undone if the copy does not succeed completely.

你可能感兴趣的:(Buffer.BlockCopy VS Array.Copy VS ConstrainedCopy)