#326 – Generic Type vs. Constructed Type

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;
Advertisement