C# Language: generics, open/closed, bound/unbound, constructed

These are examples of unbound generic types:

  • List<>
  • Dictionary<,>

They can be used with typeof, i.e., the following are valid expressions:

  • typeof(List<>)
  • typeof(Dictionary<,>)

That should answer your question 2. With respect to question 1, note that type arguments can be constructed types or type parameters. Thus, your list should be updated as follows:

public class MyClass<T, U> {  // declares the type parameters T and U

    // all of these are
    // - generic,
    // - constructed (since two type arguments are supplied), and
    // - bound (since they are constructed):

    private Dictionary<T, U> var1;     // open (since T and U are type parameters)
    private Dictionary<T, int> var2;   // open (since T is a type parameter)
    private Dictionary<int, int> var3; // closed
}

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)