Skip to content

Instantly share code, notes, and snippets.

@christiannagel
Created July 10, 2018 20:04
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 christiannagel/9fc517638c94ee6e8be0e9c24be75d99 to your computer and use it in GitHub Desktop.
Save christiannagel/9fc517638c94ee6e8be0e9c24be75d99 to your computer and use it in GitHub Desktop.
Using C# 8 Ranges with Arrays
var arr = new[] { 1, 4, 8, 11, 19, 31 };
var range = arr[2..5];
ref int elt = ref range[1];
elt = 42;
int copiedelement = range[1];
copiedelement = 11;
Console.WriteLine($"the original element is changed: {arr[3]}");
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment