Skip to content

Instantly share code, notes, and snippets.

@bonprosoft
Created September 20, 2015 13:56
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 bonprosoft/49a1755fcf8df77a8eed to your computer and use it in GitHub Desktop.
Save bonprosoft/49a1755fcf8df77a8eed to your computer and use it in GitHub Desktop.
ArraySegment<T>
class Program
{
static void Main(string[] args)
{
var foo = new[] { 0, 1, 2, 3, 4 }.ToArray();
var bar = new ArraySegment<int>(foo, 0, 2);
foo[0] = -1;
Console.WriteLine(ReferenceEquals(foo, bar.Array)); // True
Console.WriteLine(bar.ElementAt(0)); // -1
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment