Calculated Property

noun

say it: “KAL-kyuh-lay-tid PROP-er-tee” /ˈkælkjəleɪtɪd ˈprɒpərti/

A property with only a get that works out its value from other values every time it is read.

What is Calculated Property in C#?

Calculated Property — A property with only a get that works out its value from other properties each time it's read. It stores nothing, so it can never be out of date.

class Team
{
    public int Wins { get; set; }
    public int Losses { get; set; }
    public int GamesPlayed => Wins + Losses;
}

In a sentence

  • “GamesPlayed is a calculated property: Wins plus Losses, never stored.”

Level: Journeyman · More C# terms at this level

Updated