Skip to content

C# Feature ๏ฟฝ Computed properties

Computed properties return a value based on other state and avoid redundant storage.

public class Rectangle
{
public double Width { get; set; }
public double Height { get; set; }
public double Area => Width * Height; // Computed property
}
  • Keep computations cheap; cache with a lazy property if expensive.
  • Prefer methods if parameters are required for the computation.