海鸥航迹

学习之笔记,好文之收集。

导航

< 2025年4月 >
30 31 1 2 3 4 5
6 7 8 9 10 11 12
13 14 15 16 17 18 19
20 21 22 23 24 25 26
27 28 29 30 1 2 3
4 5 6 7 8 9 10

统计

[导入]Are Generics in .NET like Templates in C++?

No.

While Generic types do have a similar syntax to C++ templates, they are instantiated at runtime as opposed to compile time, and they can be reflected on via meta-data.  Also, in Generics, member access on the type paramater is verified based on the constraints placed on the type parameter; whereas, in templates, member access is verified on the type argument after instantiation.

Brandon Bray (Program Manager for the Visual C++ Compiler front-end at Microsoft) has a blog entry where he draws out the distinctions between Generics and Template.

Starting with VS 2005, C#, Managed C++, and VB will have CLR support for generics.  Read these two MSDN Magazine articles for more details. Introducing Generics in the CLR & More on Generics in the CLR

[Author: SantoshZ]


文章来源:http://blogs.msdn.com/csharpfaq/archive/2004/07/28/199940.aspx

posted on   海天一鸥  阅读(769)  评论(1编辑  收藏  举报

点击右上角即可分享
微信分享提示