Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
var array = new[] { 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H' };
Index idx1 = 2; // 2nd element from the beginning
Index idx2 = ^3; // 3rd element from the end (^)
Console.WriteLine($"{array[idx1]}, {array[idx2]}"); // prints "C, F"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.