Abstract class and interface, please refer to the difference between the abstract class and interface, I will not say, then when to select the abstract class, and when to select the interface, OK now I have a situation.
Now I define a person's class, for simplicity's sake, I write briefly, as follows:
public abstract class person
{public
abstract float getweight ();
}
Well, now I have another singer, apparently, he is a man, say inherit, as follows:
Public abstract class Singer:person
{public
abstract void singsong ();
}
Now, I have a dancer, obviously, this is also simple, he is also a person, say inheritance, as follows:
Public abstract class Dancer:person
{public
abstract void Dance ();
}
Now everything is fine, there is no problem, but, another person, he said he will sing, and dance, I call this class for Singerdancer, OK, I'm defining a class,
Public abstract class Singerdancer:singer, dancer
But is that right? C # is not allowed to inherit many, this is not permitted to compile, from another level, this obvious violation of the principle of a single responsibility, then there is no abstract class.
Let's take one more example:
Birds can fly, there is no problem, OK, first define a class first, as follows:
Public abstract class Bird
{public
abstract void Fly ();
}