问题
I've been looking through the Marshal class, but I can't seem to find a method that allows me to copy from an unmanaged array (IntPtr) to another unmanaged array (IntPtr).
Is this possible using .NET?
回答1:
You can also DllImport RtlMoveMemory to get the job done:
[DllImport("Kernel32.dll", EntryPoint="RtlMoveMemory", SetLastError=false)]
static extern void MoveMemory(IntPtr dest, IntPtr src, int size);
This will also require FullTrust, however, but as you are working with unmanaged code, I'd expect you already have it.
回答2:
You can revert to using unsafe code in C#, if that is an option (typically requires FullTrust permission, which may not be available in all cases).
来源:https://stackoverflow.com/questions/3208101/net-copy-from-unmanaged-array-to-unmanaged-array