Returns a value that indicates whether current type is generic - CSharp System.Reflection

CSharp examples for System.Reflection:Type

Description

Returns a value that indicates whether current type is generic

Demo Code

// Copyright (c) Costin Morariu. All rights reserved.
using System.Reflection;
using System.Collections.Generic;
using System;/*from   w  w  w  . j  av  a 2 s  . c  om*/

public class Main{
        /// <summary>
        /// Returns a value that indicates whether current type is generic
        /// </summary>
        /// <param name="type">Current type</param>
        /// <returns>True if current type is generic, otherwise false</returns>
        public static bool IsGenericType(this Type type)
        {
            return type.GetTypeInfo().IsGenericType;
        }
}

Related Tutorials