Sunday, July 1, 2012

Achieve polymorphism in C# .NET


How to achieve polymorphism in C#.NET?


Polymorphism is when a class can be used as more than one type through inheritance. It can be used as its own type, any base types, or any interface type if it implements interfaces.It can be achieved in the following ways.


Derived class inherits from a base class and it gains all the methods, fields, properties and events of the base class.


To completely take over a class member from a base class, the base class has to declare that member as virtual.

No comments:

Post a Comment