Skip to content

C# Feature – Expression-bodied members

Use => to define concise members (properties, methods, constructors, finalizers) when a single expression suffices.

C# 6–7 (expanded over versions)

int Inc(int x) { return x + 1; }
int Inc(int x) => x + 1;
public string Name { get; }
public override string ToString() => Name;
  • Keep bodies simple; use block bodies for complex logic.
  • Expanded across C# 6 and 7 to more member kinds.