Back to Writing
NOTEScsharpexpression-bodied-memberssyntaxprogramming
C# Expression-Bodied Members Guide
November 29, 2019•Updated Feb 17, 2026

public void A(){expression} can be changed to:
public void A() => expression;
Starting with C# 6.0, you can use the lambda operator => to shorten {} blocks.
public class Location
{
private string locationName;
public string Name { get { return locationName; } }
}
This can be refactored to:
public class Location
{
private string locationName;
public string Name => locationName;
}
Among properties with get and set, when creating a read-only property that only allows get, you can write it using the expression-bodied syntax as shown above.