Greetings.
In C#: If I have an int[] array declared like this
int[] array = new array[size];
there is an way to get the IntPtr from
You should be able to do this without unsafe code using GCHandle
. Here is a sample:
GCHandle handle = GCHandle.Alloc(array, GCHandleType.Pinned);
try
{
IntPtr pointer = handle.AddrOfPinnedObject();
}
finally
{
if (handle.IsAllocated)
{
handle.Free();
}
}
Use unsafe code, like this:
unsafe
{
fixed (int* pArray = array)
{
IntPtr intPtr = new IntPtr((void *) pArray);
}
}