2019.8.21 Class & Interface & Abstract & Attributes

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;

Use of attributes:

Console.WriteLine(person.Age);


person.Age
= 10;

Today too Sleepy. Above

Good night

interface ISuper

{
int GetSuper();
}

public int GetSuper()

{
return age + 100;
}

get {return age + 10;} set {age = value-10;//value is a specific member variable } }

public int ID// Attributes {get; set; }< /span>

person.Age = 10;

Console.WriteLine(person.Age);


person.Age
= 10;

Leave a Comment

Your email address will not be published.