Replies: 2 comments 5 replies
-
@nczsl interfaces cannot have state. There's no place for a field to go. Adding state at the DIM level is something we also feel is highly problematic due to the diamond inheritance problem. Our recommendation here is to simply define an abstract class with an impl of all hte properties (which can be autoprops), and then derive from that. As class inheritance doesn't allow for multiple-inheritance, there's no diamond problem here. |
Beta Was this translation helpful? Give feedback.
-
So, if there is a field of the same type in the implementation class with the same name and lowercase, then if the class has the corresponding automatic property in the implemented interface, otherwise it is still handled according to the original rules, that is, the automatic property of the interface is still not implemented, unless there is a corresponding field of the same type with the same name (starting with lowercase) in the inheritance class. |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
It is recommended to support the implementation of the interface, and the contentless properties defined in the interface are not considered to be an interface implementation, but there is a need for this, which is valuable because it avoids duplicate implementation properties of the class of the interface
interface A{
int X{get; set;}
} // Now that this X is treated as a non-implementation, I can't find a way to make such a property be implemented by default, if it is the default implementation then it is much more convenient, right?
Beta Was this translation helpful? Give feedback.
All reactions