What is a property in C#?
Experience Level: Junior
Tags: C#
Answer
In C# a property is used to store a value to an object or retrieve a value from an object. You may want to store multiple different values to an object. In such case you would define one property for each value. Each property would have its data type that defines what type of value can be stored to the property or retrieved from the property.
Imagine you would like to have an object that represents a person. By what data values would you want to describe a person? Maybe Height? Weight? Age? Name? Eye color? Date of birth? All these values could be properties.
Related C# job interview questions
How can you assign a value to a property in C#?
C# JuniorHow can you recognize a property in C#?
C# JuniorWhat is a class instance in C#?
C# JuniorWhat is a difference between value type and reference type?
C# JuniorWhat is an object reference in C#?
C# Junior