#326 – Generic Type vs. Constructed Type
May 17, 2011 1 Comment
Once a generic type is provided with type arguments, it is known as a constructed type.
Here is the definition of a generic type:
// A generic type
public class ThingContainer<TThing1, TThing2>
{
public TThing1 Thing1;
public TThing2 Thing2;
}
You declare instances of the generic type by providing arguments for its type parameters. The type name with the arguments is the constructed type.
// ThingContainer<Dog, DateTime> is a constructed type
ThingContainer<Dog, DateTime> container = new ThingContainer<Dog, DateTime>();
container.Thing1 = new Dog("Bob");
container.Thing2 = DateTime.Now;
Pingback: #534 – What Good Are Generics? « 2,000 Things You Should Know About C#