. Net Video Learning 3rd-quarter C # Object-oriented
Object-oriented interface
A class in C + + can inherit from more than one class, but is not allowed in C #. So if you want to implement similar operations, you need an interface, the keyword interface
Public class person{} Public Interface iable{ void Test ();} Public class student:person,iable{ void Test () { Console.WriteLine (" test");} }
The interface name usually begins with I able end.
A method in an interface can have a return value, but a member in an interface cannot be decorated by an access modifier, the default is public (and the members in the class are defaulted by default, members of the class are private by default), and interface members are not allowed to be defined (abstract methods of abstract classes cannot be defined)---cannot have method bodies.
Property has only automatic properties. (Write-only properties, no fields, fields are automatically generated, loss of protected field function because the get and set of automatic attributes have no method body)
. NET Learning 3rd-quarter C # object-oriented interface