Interview Question

What is a property?

A property exposes controlled value access through accessors.

💡 Concept ✅ Quick Revision 🔷 C#

Answer

A property is a member that provides field-like access through accessors. • A get accessor reads a value and a set or init accessor supplies a value. • Properties can validate, calculate, or control access instead of exposing a field directly. • An auto-implemented property lets the compiler provide the backing storage.

💡 C# Example

public class Person { public required string Name { get; init; } public int Age { get; private set; } }

⚡ Quick Revision

A property exposes controlled value access through accessors.