C# Language void*


Example

C# inherits from C and C++ the usage of void* as a type-agnostic and size-agnostic pointer.

void* ptr;

Any pointer type can be assigned to void* using an implicit conversion:

int* p1 = (int*)IntPtr.Zero;
void* ptr = p1;

The reverse requires an explicit conversion:

int* p1 = (int*)IntPtr.Zero;
void* ptr = p1;
int* p2 = (int*)ptr;