According to MSDN, "Generics and templates are both
language features that provide support for parameterized types. However, they
are different and have different uses." C# generics and templates in C++
are more or less similar syntactically. However, there are some notable differences
between them. C# Generic types are strong typed and they are instantiated at
the runtime whereas C++ Templates are loosely typed and they are instantiated at
the compile time only. Further, unlike C++ templates, Generics do not permit the
type parameters to have default values.
MSDN states, "C++ templates use a compile-time model.
When a template is used in a C++ program, the effect is as if a sophisticated
macro processor had been used. C# generics are not just a feature of the
compiler, but also a feature of the runtime. A generic type such as
List<T> maintains its generic-ness (genericity) after it has been
compiled. Or, to look at it another way, the substitution that the C++ compiler
does at compile time is done at JIT time in the C# generic world."