How to declare a void pointer in C#

心不动则不痛 提交于 2019-12-17 16:58:19

问题


How can we declare a void pointer in C#?


回答1:


void* identifier; as described here

But it needs to be in unsafe as:

unsafe
{
    void* identifier;
}

And unsafe code has to have been allowed for the project.




回答2:


I'm assuming you mean in managed code, as your question is rather short to do anything but assume.

I think you're either looking for IntPtr or simply any object reference (which is the base type, and the basic equivalent of a null pointer - a reference to "something"). Unless you mean null pointer, in which case you're looking for IntPtr.Zero.




回答3:


there's something here:

http://msdn.microsoft.com/en-us/library/y31yhkeb%28VS.80%29.aspx



来源:https://stackoverflow.com/questions/3069448/how-to-declare-a-void-pointer-in-c-sharp

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!