C# Feature β Expression-bodied members
Overview
Section titled βOverviewβUse => to define concise members (properties, methods, constructors, finalizers) when a single expression suffices.
Introduced In
Section titled βIntroduced InβC# 6β7 (expanded over versions)
int Inc(int x) { return x + 1; }int Inc(int x) => x + 1;Annotated Example
Section titled βAnnotated Exampleβpublic string Name { get; }public override string ToString() => Name;Gotchas & Best Practices
Section titled βGotchas & Best Practicesβ- Keep bodies simple; use block bodies for complex logic.
Related Features
Section titled βRelated FeaturesβVersion Notes
Section titled βVersion Notesβ- Expanded across C# 6 and 7 to more member kinds.