I\'ve read some information about generics in .ΝΕΤ and noticed one interesting thing.
For example, if I have a generic class:
class Foo
{
As opposed to C++ templates, .NET generics are evaluated in runtime, not at compile-time. Semantically, if you instantiate the generic class with different type parameters, those will behave as if it were two different classes, but under the hood, there is only one class in the compiled IL (intermediate language) code.
The difference between different instantiatons of the same generic type becomes apparent when you use Reflection: typeof(YourClass will not be the same as typeof(YourClass. These are called constructed generic types. There also exists a typeof(YourClass<>) which represents the generic type definition. Here are some further tips on dealing with generics via Reflection.
When you instantiate a constructed generic class, the runtime generates a specialized class on the fly. There are subtle differences between how it works with value and reference types.
For generic methods, the principles are the same.