get generic arguments of generic class
Published: 13. December 2008 | Updated: 13. December 2008License: Microsoft Public License (MS-PL)
Categories: Framework » Generics
Tags: C# Generics Reflection
Snippet example shows how to get generic arguments of generic class
Import namespaces
using System.Collections.Generic;
Code
Dictionary<int, string> dictionary = new Dictionary<int, string>(); Type type = dictionary.GetType(); Type[] arguments = type.GetGenericArguments(); foreach (Type argument in arguments) { Console.WriteLine(argument); }Console Output:
System.Int32
System.String
System.String
| Send us feedback about this snippet » |





