指向3d数组的指针

时间:2011-03-15 12:36:49

标签: c# unsafe intptr

我有一个3D阵列,我想让IntPtr指向它,所以我在这里做了什么..可以有人告诉我,如果它是对的......

fixed (Int16* mypointer = &myvolume[0, 0, 0])
{
     //then i cast mypointer as IntPtr
}

请注意myvolume的尺寸为200 x 100 x 100

1 个答案:

答案 0 :(得分:3)

你确定你真正想要的是一个不安全的指针吗?使用这样的指针在C#land中非常罕见。

Eric Lippert最近写了一篇关于simple class that offers some of the behavior of pointers的文章,没有使用不安全的代码。您可以考虑将其扩展为使用多维数组。

相关问题