What is compile time and runtime polymorphism in c# [Resolved]

Posted by Jitendrasoft09 under C# on 6/26/2013 | Points: 10 | Views : 18752 | Status : [Member] [MVP] | Replies : 4
Hi All,
I want to understand What is compile time and runtime polymorphism in c#, let me know if anybody knows

Jitendra Kumar
If my post helps you, plz mark as an answer.



Responses

Posted by: Niladri.Biswas on: 6/26/2013 [Member] Platinum | Points: 50

Up
0
Down

Resolved
Method overloading is compile time Polymorphism while Method overriding is run time Polymorphism.

It's because function overloads are resolved at the compile time. This is called static or earlier binding(Compiletime Polymorphism)

And virtual methods overrides are resolved at the runtime. This is called dynamic or late binding(Runtime Polymorphism)


Best Regards,
Niladri Biswas

Jitendrasoft09, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Niladri.Biswas on: 6/26/2013 [Member] Platinum | Points: 25

Up
0
Down
http://www.dickbaldwin.com/csharp/Cs000120.htm

Best Regards,
Niladri Biswas

Jitendrasoft09, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Satyapriyanayak on: 6/27/2013 [Member] [MVP] Silver | Points: 25

Up
0
Down
Compile time Polymorphism or Early Binding

The polymorphism in which compiler identifies which polymorphic form it has to execute at compile time it self is called as compile time polymorphism or early binding.

Advantage of early binding is execution will be fast. Because every thing about the method is known to compiler during compilation it self and disadvantage is lack of flexibility.

Examples of early binding are overloaded methods, overloaded operators and overridden methods that are called directly by using derived objects.

Runtime Polymorphism or Late Binding

The polymorphism in which compiler identifies which polymorphic form to execute at runtime but not at compile time is called as runtime polymorphism or late binding.

Advantage of late binding is flexibility and disadvantage is execution will be slow as compiler has to get the information about the method to execute at runtime.

Example of late binding is overridden methods that are called using base class object.

If this post helps you mark it as answer
Thanks

Jitendrasoft09, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Jitendrasoft09 on: 6/27/2013 [Member] [MVP] Starter | Points: 25

Up
0
Down
Good effort Satya.., nice explanation with short statement Niladri...

Jitendra Kumar
If my post helps you, plz mark as an answer.

Jitendrasoft09, if this helps please login to Mark As Answer. | Alert Moderator

Login to post response