Back to Writing
NOTEScsharpexpression-bodied-memberssyntaxprogramming

C# Expression-Bodied Members Guide

November 29, 2019Updated Feb 17, 2026

![](

ChusHSphP4wZzF_8HUg.7frUN558cxoWG3wCCYqKP0BeoWAkyY-XDI89ha4CpVkg.PNG.cdw0424/csharp.png?type=w966)

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.

Expression-Bodied Members - C# Programming Guide