How to declare a void pointer in C#

2019-01-15 19:52发布

问题:

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



标签: c# c#-4.0 void