ASP.Net中的多态性 [英] Polymorphism in ASP.Net

查看:55
本文介绍了ASP.Net中的多态性的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述




我在最近的一次采访中被问到一个问题,在ASP.Net中使用了多少
多态?


我从不同的人那里得到了不同的答案,

一个人说ToString()方法,因为它适用于不同的类。

一个人说OnInit()方法System.Web.UI.Page类,因为它被定义为虚拟的
,这是多态的关键。


最简洁的定义我可以找到多态:

同样的方法对不同的类有不同的反应。


有什么意见吗?


谢谢提前

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

推荐答案

我不是这方面的专家,但我认为这是在使用相同的方法时br />
在同一个类中多次,并且具有不同的接口。

最明显的例子是类中的重载构造函数和

一般任何重载的方法。

--Buddy

Danny Ni < DN ** @ yahoo.com>在留言中写道

新闻:uY ************** @ TK2MSFTNGP12.phx.gbl ...
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

"Danny Ni" <dn**@yahoo.com> wrote in message
news:uY**************@TK2MSFTNGP12.phx.gbl...

在最近的一次采访中我被问到一个问题,在ASP.Net中使用了多态?

我从不同的人那里得到了不同的答案,
有人说ToString()方法,因为它适用于不同的类。
一个说System.Web.UI.Page类的OnInit()方法,因为它的定义是虚拟的,那是关键多态性。

我可以找到多态的最简洁的定义:
同样的方法对不同的类别有不同的反应。

任何评论?
提前致谢
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



Buddy Ackerman< bu ************** @ buddyackerman.com> ;写道:
Buddy Ackerman <bu**************@buddyackerman.com> wrote:
我不是这方面的专家,但我认为这是同一个方法在同一个课程中多次使用并且具有不同的界面。
最明显的例子是类中的重载构造函数和
一般任何重载的方法。
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.




否,重载不是'' t多态 - 覆盖是多态的。


-

Jon Skeet - < sk *** @ pobox.com>
http://www.pobox.com/~skeet

如果回复小组,请不要给我发邮件



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

--
Jon Skeet - <sk***@pobox.com>
http://www.pobox.com/~skeet
If replying to the group, please do not mail me too


Jon Jon,


只是OP的补充。


可以在ASP.NET中使用。


Cor
Hi Jon,

Just an addition for the OP.

And can be used in ASP.NET.

Cor

不,重载不是'多态 - 覆盖是多态。

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



这篇关于ASP.Net中的多态性的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆