Skip to content

Instantly share code, notes, and snippets.

@aevitas
Created March 10, 2020 15:39
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save aevitas/1115e838173f0b3db2f9a0ce598e990a to your computer and use it in GitHub Desktop.
Save aevitas/1115e838173f0b3db2f9a0ce598e990a to your computer and use it in GitHub Desktop.
public static unsafe void TypeSafety()
{
int a = 1;
var ptr = Unsafe.AsPointer(ref a);
Unsafe.Write(ptr, 0);
var b = Unsafe.Read<bool>(ptr);
Console.WriteLine(b);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment