Output the type information about the generic parameters

image_pdfimage_print
   
 


using System;
using System.Collections.Generic;
using System.Text;

public class OneParamType<T> {}

public class TwoParamType<T, U> {}

public class TypeDumper<T, U, V> {
    public static void DumpTypeInfo() {
        Console.WriteLine(typeof(T));
        Console.WriteLine(typeof(U));
        Console.WriteLine(typeof(V));
        Console.WriteLine(typeof(OneParamType<String>));
        Console.WriteLine(typeof(OneParamType<T>));
        Console.WriteLine(typeof(TwoParamType<U, int>));
        Console.WriteLine(typeof(TwoParamType<T, V>));
    }

    public static void ShowTypeInfo() {
        TypeDumper<String, int, Double>.DumpTypeInfo();
    }    
}

             


This entry was posted in Generics. Bookmark the permalink.