First, the interface does not need to use public, because the interface must be public, and the methods in the abstract class can be separated.
Also, the interface cannot contain fields, but can contain attributes.
An error occurred during compilation after changing it to an attribute, because the class that implements the interface must also implement this attribute!
At this time, a small menu will appear when you wait for a moment on the interface name behind the class. After you click the implementation interface, the code will be automatically generated in its inheritance class to reduce the input.
The final test code is as follows:
Class program {static void main (string [] ARGs) {I display player = new screen (); player. in ("video"); player = new digital playback (); player. in (15); console. readline () ;}} interface I show {string STR {Get; set;} Where is the void (object);} Class Screen: I show {public void (where is the object) {console. writeline ("show {0} on the screen", (string) Where);} class digital playback: I show {public void (where the object is) {console. writeline ("{0} in number", (INT) Where);} Public String STR {get {Throw new notimplementedexception ();} set {Throw new notimplementedexception ();}}}
I remember that the abstract class is similar to the interface, and the interface pays more attention to the extraction of the same function. For example, the flight function allows both planes and birds to fly, but it is shown that they do not belong to the same class, there is no inheritance relationship. It is not appropriate to use abstract classes to implement them. Using Interfaces avoids an Inheritance Problem and focuses only on the implementation of functions. In a word, if you have the same functions, you can use the interface (too long ..)