Skip to content

Instantly share code, notes, and snippets.

@Ibro Ibro/Tuples.cs
Created Oct 28, 2017

Embed
What would you like to do?
Tuples in C# 7
List<int> numbers = new List<int> { 3, 5, 11, 4, 7 };
var result = GetLowestHighest(numbers);
Console.WriteLine(result.Item1); // ugly?
Console.WriteLine(result.Item2); // yeah, ugly..
// Notice the return type of the method. It's 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
You can’t perform that action at this time.