Templates and Generics

Few days before I downloaded "Introduction to Generics - Part 1" video from LearnVisualStudio.NET. But it gave me impression that Generic is same as template as in C++. But after googling I found No, there are some differences.

Well, as far simple implementation concerns ... I can say similarity ... but if you go bit deeper ... there are much differences. However, there is no doubt that Generics are improved form of templates.

Generics and templates have a minor overlap in functionality. They both make it possible to create parameterized types which make it possible to create type safe collections

 	                        Generics	            Templates
Constraint mechanism
Subtype constraints Lazy structural constraints
Allows explicit specialization No Yes
Allows partial specialization No Yes
Type identity of specialization Globally unique Unique to each assembly
Cross language facility Yes No
Allowed parameters Ref class, value class only All types and non-type
Name lookup and binding At definition, to constraints At specialization, to type

For further reading check out this


Popular posts from this blog


Khuda Karay K Meri Arz -e- Pak Par Utray

کولہوں کے بیل