Skip to content

Instantly share code, notes, and snippets.

@TryJSIL
Created February 24, 2013 11:57
Show Gist options
  • Save TryJSIL/5023560 to your computer and use it in GitHub Desktop.
Save TryJSIL/5023560 to your computer and use it in GitHub Desktop.
Unsafe Code Test
using System;
public static class Program {
public static unsafe void Main (string[] args) {
var ints = new int[] { 0, 1, 2, 3 };
fixed (int* pInts = ints) {
var pBytes = (byte*)pInts;
for (var i = 0; i < (ints.Length * 4); i++)
pBytes[i] += 1;
}
foreach (var i in ints)
Console.WriteLine(i);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment