Polymorphism can be achieved in 3 ways:
Runtime polymorphism means, compiler would come to know which method to execute, at runtime not compile time. We can implement the runtime polymorphism by using override keyword.
Late binding
Reference:
http://www.dickbaldwin.com/csharp/Cs000120.htm
Difference between compile time & run time polymorphism:
- Method overloading (compile time polymorphism
- Method overriding through inheritance (runtime polymorphism)
- Method overriding through C# interface (runtime polymorphism)
Late binding
- The decision as to which version of method to invoke cannot be made at compile time.
- It has to be done at run-time.
- This is reffered as late binding
Difference between compile time & run time polymorphism:
- override functions have same signatures, but implemented in different classes
- overload is function with same name but different signatures in same class
No comments:
Post a Comment