Tsallaka zuwa abun ciki
Justice Tech School

Tuples and Deconstruction

Tuples group values without a class. Deconstruct them into variables.

Example
(string Name, int Age) p = ("Ada", 30);
Console.WriteLine($"{p.Name} {p.Age}");
var (name, age) = p;
static (int min, int max) Range(int[] a) => (a.Min(), a.Max());
Console.WriteLine(Range(new[] { 3, 1, 4 }));

Exercise

Group values.

var t = (1, );

Quiz Test

What are tuples for?

These free lessons are for learning. Join a full course for projects, mentor feedback and a verified certificate.