如何投放的IntPtr为字节* [英] How to cast IntPtr to byte*
本文介绍了如何投放的IntPtr为字节*的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我打电话通过互操作,返回一个出的IntPtr
参数的方法。我怎样才能得到一个字节*
此的IntPtr
这样我就可以对它进行操作?我试过如下:
I'm calling a method via interop that returns an out IntPtr
parameter. How can I get a byte*
for this IntPtr
so I can operate on it? I tried the following:
fixed(byte* ptr = (byte)myIntPtr)
但它没有工作。 !任何帮助,将不胜感激。
but it didn't work. Any help would be appreciated!
推荐答案
您可以简单的写:
byte* ptr = (byte*)int_ptr;
您不必使用的固定的关键字。你不想到引脚IntPtr的,你呢?
You don't have to use the fixed keyword. You don't want to pin the IntPtr, do you?
这篇关于如何投放的IntPtr为字节*的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文