Hello,
I googled this question but I cannot understand it well.
In C#, We can have a property in interfaces but we cannot have fields. Could you please why?
I've seen the below description here
Interfaces don’t allow fields because they consist of a contract that is a **list of methods**, whose implementation is provided by a class. **Properties are implemented as methods (get and set accessors)**, so they fit this model. But fields are just data locations, so it doesn’t make sense to include them in an interface.
Is it true? In C#, Are Properties implemented as methods (get and set accessors)?
Hello,
I googled this question but I cannot understand it well.
In C#, We can have a property in interfaces but we cannot have fields. Could you please why?
I've seen the below description here
Interfaces don’t allow fields because they consist of a contract that is a **list of methods**, whose implementation is provided by a class. **Properties are implemented as methods (get and set accessors)**, so they fit this model. But fields are just data locations, so it doesn’t make sense to include them in an interface.Is it true? In C#, Are Properties implemented as methods (get and set accessors)?