C# Feature ๏ฟฝ Computed properties
Overview
Section titled โOverviewโComputed properties return a value based on other state and avoid redundant storage.
Example
Section titled โExampleโ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.