Skip to content

C# Feature – Deconstruction

Deconstruction syntax assigns multiple values in one statement from tuples or types with Deconstruct methods.

C# 7 (2017)

var t = GetPoint();
var x = t.X; var y = t.Y;
var (x, y) = GetPoint();
public readonly struct Point(int x, int y)
{
public int X { get; } = x;
public int Y { get; } = y;
}
  • Ensure Deconstruct methods are in scope.
  • Extended patterns support richer deconstruction cases.