Generic type names

Generic type names are suffixed with the ' symbol, followed by the number of type parameters.

If the generic type is unbound, this rule applies to both Name and FullName:

 
using System;
using System.Reflection;
using System.Collections.Generic;

class MainClass
{
    static void Main()
    {
        Type t = typeof(Dictionary<,>); // Unbound
        Console.WriteLine(t.Name);  // Dictionary'2
        Console.WriteLine(t.FullName);  // System.Collections.Generic.Dictionary'2


    }

}
  

The output:


Dictionary`2
System.Collections.Generic.Dictionary`2

If the generic type is closed, FullName (only) acquires a substantial extra appendage.

Each type parameter's full assembly qualified name is enumerated:

 
using System;
using System.Reflection;
using System.Collections.Generic;

class MainClass
{
    static void Main()
    {
        Console.WriteLine(typeof(Dictionary<int, string>).FullName);

    }

}
  

The output:


System.Collections.Generic.Dictionary`2[[System.Int32, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089],[System.String, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089]]
java2s.com  | Contact Us | Privacy Policy
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.