What is void* in C#?
c#, c++, visual-c++
Solution
In general, `void*` would be converted to `IntPtr` in C# code.
Edit with a bit more information: `IntPtr` in .NET/C# often behaves like an opaque handle. You can't directly dereference it, obtain "size" information from it (e.g. the size of an array you're pointing at), and it doesn't try to tell you what data type it's pointing at - or even if it's a pointer at all. When you are translating C/C++ code to C# and you see `void*`, the C# code should be written with `IntPtr` until you have a better idea what exactly you're dealing with.
The pinvoke.net site has two entries for `glTexImage2D`, depending on where the image data is stored. If the image data is stored in a managed `byte[]` in .NET/C#, you call the version that passes a `byte[]`. If the image data is stored in unmanaged memory and you only have an `IntPtr` to the data in the C# code, you call the version that passes an `IntPtr`.
Examples from pinvoke.net opengl32:
[DllImport(LIBRARY_OPENGL)] protected static extern void glTexImage2D (
uint target,
int level,
int internalformat,
int width,
int height,
int border,
uint format,
uint type,
byte[] pixels);
[DllImport(LIBRARY_OPENGL)] protected static extern void glTexImage2D (
uint target,
int level,
int internalformat,
int width,
int height,
int border,
uint format,
uint type,
IntPtr pixels);
Problem
I'm looking through the source of a VC++ 6.00 program.i need convert this source to C# but i can not understand what is (void*) in this example? ``` glTexImage2D( GL_TEXTURE_2D, 0, GL_RGBA8, IMAGE_WIDTH, IMAGE_HEIGHT, 0, PIXEL_FORMAT, GL_UNSIGNED_BYTE, (void*)imageData ); ``` in this code imagedata is a pointer byte* imageData