Created
September 20, 2015 13:56
-
-
Save bonprosoft/49a1755fcf8df77a8eed to your computer and use it in GitHub Desktop.
ArraySegment<T>
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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