C#面试问题2

32. What is polymorphism

多态性: There is one list, but it's elements can take many forms.

the derived types can bu used in place of the base type.

What mechanisms in C# allow us to use polymorphism?

interfaces, abstract classes, inheritance, virtual methods and generics.

33. What's the difference between a virtual method and abstract method

virtual method: In base class, it has an implementation, and it gives the inheriting classe an option to provide it's own implementation.

虚方法是实现多态的一个方法。

static methods cannot be virtual.

抽象方法:In base class, it does not have an implementation, and must be overriden.

They all can be applied to properties, indexers, and events.

What is method overriding?

It's providing a custom implementation of a virtual of abstract method in the child class.

你可能感兴趣的:(C#,之,MVC5,学习,c#,开发语言)