Skip to content

Instantly share code, notes, and snippets.

@Ibro
Created November 1, 2017 03:28
Show Gist options
  • Save Ibro/b066f955b6907dbc2bc3f761223cbe39 to your computer and use it in GitHub Desktop.
Save Ibro/b066f955b6907dbc2bc3f761223cbe39 to your computer and use it in GitHub Desktop.
Desconstruction in C# 7
(int highest, int lowest) = GetLowestHighest(numbers);
// Notice the return type of the method. It is tuple
private static(int, int) GetLowestHighest(IReadOnlyCollection < int > numbers) {
int lowest = numbers.Min(n => n);
int highest = numbers.Max(n => n);
return (lowest, highest);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment