I want to bind a typically typed array and get a pointer to its memory:
T[] arr = ...; fixed (T* ptr = arr) {
But trying to compile the above code causes a compiler error:
Cannot take the address of, get the size of, or declare a pointer to a managed type
The answers of the questions confirm that there is no way to declare a common T* pointer. But is there a way to bind a shared array of T[] and get IntPtr to pinned memory? (Such a pointer is still used because it can be passed into native code or transferred to a pointer of a known type.)
source share