Should an interface have properties?
Besides, cAN interface have properties?
Like a class, Interface can have methods, properties, events, and indexers as its members. But interfaces will contain only the declaration of the members. The implementation of interface's members will be given by class who implements the interface implicitly or explicitly.
Beside above, can we define properties in Interface C#? In C#, a class or a struct can implement one or more interfaces. In C#, an interface can be defined using the interface keyword. Interfaces can contain methods, properties, indexers, and events as members. An interface can only contain declarations but not implementations.
Also know, why do we need interface?
interface allows a class to behave like multiple types, which is not possible without multiple inheritance of class. It also ensures that you follow programming to interface than implementation pattern, which eventually adds lot of flexibility in your system.
Why interface Cannot have fields?
An interface can contain methods, properties, events or indexers. It cannot contain fields. 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.