Returns generic argument types of the current type - CSharp System.Reflection

CSharp examples for System.Reflection:Type

Description

Returns generic argument types of the current type

Demo Code

// Copyright (c) Costin Morariu. All rights reserved.
using System.Reflection;
using System.Collections.Generic;
using System;//  w  w  w .ja  v a  2s  .com

public class Main{
        /// <summary>
        /// Returns generic argument types of the current type
        /// </summary>
        /// <param name="type">Current type</param>
        /// <returns>An array containing the types of generic arguments</returns>
        public static Type[] GetGenericArguments(this Type type)
        {
            return type.GetTypeInfo().GenericTypeArguments;
        }
}

Related Tutorials