仿制药是多态的吗? [英] Are generics form of polymorphism ?

查看:116
本文介绍了仿制药是多态的吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



我对术语多态性有明确的想法,我仍然对仿制药感到好奇。我们可以将泛型视为多态吗?如果说明相同的任何链接可以与有问题的视图一起共享将会很有帮助。

推荐答案

不,我们不能。



假设我们有一些对象;并且通过实例化一些泛型类来创建这些对象中的一些或全部。让我们看一下这些对象的运行时类型。所有类型都不是通用的,因为在我们可以实例化一个对象之前,我们需要将泛型类型实例化为完整类型,而不是泛型类型。换句话说,运行时类型的对象永远不是通用的。这样,我们可以在讨论多态时不考虑这个特性。



-SA
No, we cannot.

Let's suppose we have some set of objects; and some or all of those objects have been created by instantiation of some generic classes. Let's look at the runtime types of those objects. All the types are not generic, because, before we can instantiate an object, we needed to instantiate a generic type to become a complete type, not a generic type. In other words, run-time types of objects are never generic. This way, we can exclude this feature from consideration when discussing polymorphism.

—SA


泛型和多态可以协同工作 - http:// msdn.microsoft.com/en-us/library/vstudio/dd799517%28v=vs.100%29.aspx [ ^ ]。
Generics and polymorphism can be made to work together - http://msdn.microsoft.com/en-us/library/vstudio/dd799517%28v=vs.100%29.aspx[^].


这篇关于仿制药是多态的吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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