You can use typeof
to obtain array types and generic types as follows:
using System;
using System.Reflection;
using System.Collections.Generic;
class MainClass
{
static void Main()
{
Type t3 = typeof(DateTime[]); // 1-d Array type
Console.WriteLine(t3);
Type t4 = typeof(DateTime[,]); // 2-d Array type
Console.WriteLine(t4);
Type t5 = typeof(Dictionary<int, int>); // Closed generic type
Console.WriteLine(t5);
Type t6 = typeof(Dictionary<,>); // Unbound generic type
Console.WriteLine(t6);
}
}
The output:
System.DateTime[]
System.DateTime[,]
System.Collections.Generic.Dictionary`2[System.Int32,System.Int32]
System.Collections.Generic.Dictionary`2[TKey,TValue]
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. |