Interface:
Definition: an interface is a name set composed of one or more abstract members related to semantics. The interface indicates the actions that must be supported by the specified class or structure.
-> The interface contains members without access modifiers (because all interface members are implicitly set to public and abstract.
-> All the Members defined in the interface must be implemented in the class or structure to implement it.
Comparison between interfaces and abstract classes:
-> Similarities: When a class is derived from an abstract base class, it must implement the details of the abstract method (if the derived class is not declared as abstract)
-> Differences: abstract base classes can not only define a set of abstract methods, but also specify public, private, and protected state data and many entity methods that can be accessed by quilt classes.
How can I dynamically determine the interfaces supported by a type?
1. Explicit forced conversion: IPointy a = (IPointy) B; requires structured exception handling; not recommended.
2. as keyword (get interface reference): You can get a reference pointing to this object interface in the statement using this keyword; otherwise, a null reference with a value of null will be returned.
IPointy a = B as IPointy; if (! = Null) {} else {}
3. is keyword (get interface reference): If the object to be checked does not match the specified interface, false is returned.
If (B is IPointy) {} else {}
Explicit interface implementation:
-> You cannot add access modifiers when defining explicit implementation members.