Skip to content

Instantly share code, notes, and snippets.

@Kir-Antipov
Created July 15, 2019 09:58
Show Gist options
  • Save Kir-Antipov/89f2ecb9d0e2a43cffe5f2f615882381 to your computer and use it in GitHub Desktop.
Save Kir-Antipov/89f2ecb9d0e2a43cffe5f2f615882381 to your computer and use it in GitHub Desktop.
How to create an object of type void
public class MyVoid
{
public static readonly MyVoid Instance = new MyVoid();
private MyVoid()
{
unsafe
{
MyVoid it = this;
TypedReference typedReference = __makeref(it);
IntPtr* pointer = (IntPtr*)(**(IntPtr**)&typedReference).ToPointer();
pointer[0] = typeof(void).TypeHandle.Value;
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment