1. Create interFace
interface ISuper
{
int GetSuper();
}
Classes can inherit multiple interfaces, or can only inherit a single abstract class.
Implementation in inherited classes
public int GetSuper()
{
return age + 100;
}
The difference between InterFace and abstract: abstract classes cannot be instantiated, they are inherited by other classes to implement specific methods, including class field abstract methods, and interfaces are rules , Cannot have member variables, fields
The creation of attributes (two types) public int Age//genus {
< span style="color: #0000ff;">get {return age + 10;} set {age = value-10;//value is a specific member variable } }
public int ID//attributes {get; set; }
The attribute can be set to a value (default is 0):
< div class="code">
person.Age = 10;