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]
本文探讨了CLR(公共语言运行时)中C#、Managed C++和VB.NET的泛型与C++模板之间的主要区别。重点在于泛型在运行时实例化而非编译时,并可通过元数据进行反射。此外,还介绍了类型参数访问约束验证机制的不同。
3105

被折叠的 条评论
为什么被折叠?



