Polymorphism in ASP.Net

D

Danny Ni

Hi,

I was asked a question in a recent interview, where in ASP.Net is
polymorphism used?

I got differrent answers from different people,
One said ToString() method because it is working for different classes.
One said OnInit() method of System.Web.UI.Page class because it's defined
virtual and that's the key to polymorphism.

The most concise definition I can find for polymorphism:
Same method reacts differently for different class.

Any comments?

Thanks in Advance
 
B

Buddy Ackerman

I'm not THE expert on this but I think it's when the same method is used
multiple times within the same class and has a different interface. The
most obvious example is the overloaded constructors in the classes and in
general any method that is overloaded.


--Buddy
 
J

Jon Skeet [C# MVP]

Buddy Ackerman said:
I'm not THE expert on this but I think it's when the same method is used
multiple times within the same class and has a different interface. The
most obvious example is the overloaded constructors in the classes and in
general any method that is overloaded.

No, overloading isn't polymorphism - overriding is polymorphism.
 
J

Jay B. Harlow [MVP - Outlook]

D

Danny Ni

Thank you all very much for making me more confused.
Does that mean OnInit() method exhibit polymorphism?

Thanks Again
 
J

Jay B. Harlow [MVP - Outlook]

Danny,
Yes, as it virtual, virtual means you can overload.

Jay
 
J

Jon Skeet [C# MVP]

Jay B. Harlow said:
Yes, as it virtual, virtual means you can overload.

No, virtual means you can *override*.

(I know this was just a slip of the fingers - I'm only correcting it
for the OP's benefit :)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top