Skip to content

Instantly share code, notes, and snippets.

@bojanrajkovic
Created November 6, 2010 20:48
Show Gist options
  • Save bojanrajkovic/665708 to your computer and use it in GitHub Desktop.
Save bojanrajkovic/665708 to your computer and use it in GitHub Desktop.
csharp> using System.Runtime.InteropServices;
csharp> BitConverter.GetBytes (32);
{ 32, 0, 0, 0 }
csharp> var bytes = BitConverter.GetBytes (32);
csharp> var handle = GCHandle.Alloc (bytes, GCHandleType.Pinned);
csharp> int value;
csharp> Marshal.PtrToStructure (handle.AddrOfPinnedObject (), value);
csharp> value;
0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment