The following C++ program compiles and runs as expected:
#include int main(int argc, char* argv[]) { int* test = new int[10]; for (
You need to pin the array using the fixed keyword so it won't get moved by the GC:
fixed
fixed (int* test = new int[10]) { // ... }
However, unsafe code in C# is more the exception than the rule. I'd try to translate your C code to non-unsafe C# code.