开发者

pointer to 3d array

开发者 https://www.devze.com 2023-02-17 02:36 出处:网络
i have a 3D array and i want to get IntPtr to point on it so here what i did ..can anyone tell me if it\'s right or not...

i have a 3D array and i want to get IntPtr to point on it so here what i did ..can anyone tell me if it's right or not...

fixed (Int16* mypointer = &myvolume[0, 0, 0])
{
     //the开发者_JAVA百科n i cast mypointer as IntPtr
}

notice that myvolume is of dimensions 200 x 100 x 100


Are you sure that what you really want is an unsafe pointer? Using pointers like this is very very rare in C# land.

Eric Lippert recently wrote about a simple class that offers some of the behavior of pointers, without resorting to unsafe code. You might consider extending it to work with your multidimensional arrays.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号