How to achieve polymorphism in C#?

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.
Implementation inheritance and interface inheritance - C#.NET
What are implementation inheritance and interface inheritance? - Implementation inheritance is achieved when a class is derived from another class in such a way that it inherits all its members...
How to add a ReadOnly property in C#.NET
How to add a ReadOnly property in C#.NET? - Properties can be made read-only by having only a get accessor in the implementation...
How to prevent a class from being inherited in C#.NET
How to prevent a class from being inherited in C#.NET? - The sealed modifier is used to prevent derivation from a class...
Post your comment