C# TypeInfo IsGenericTypeDefinition

Description

TypeInfo IsGenericTypeDefinition Gets a value indicating whether the current Type represents a generic type definition, from which other generic types can be constructed.

Syntax

TypeInfo.IsGenericTypeDefinition has the following syntax.


public virtual bool IsGenericTypeDefinition { get; }

Example


using System;//from www  .ja v  a 2s. c om
using System.Reflection;

public class Base<T, U> {}

public class Derived<V> : Base<string, V>
{
    public G<Derived <V>> F;

    public class Nested {}
}

public class G<T> {}

class Example
{
    public static void Main()
    {
        Type t = typeof(Derived<>);

        Console.WriteLine("    Type: {0}", t);

        Console.WriteLine("\t            IsGenericType: {0}", t.IsGenericType);
        Console.WriteLine("\t  IsGenericTypeDefinition: {0}", t.IsGenericTypeDefinition);
        Console.WriteLine("\tContainsGenericParameters: {0}", t.ContainsGenericParameters);
        Console.WriteLine("\t       IsGenericParameter: {0}", t.IsGenericParameter);
    }
}

The code above generates the following result.





















Home »
  C# Tutorial »
    System.Reflection »




EventInfo
FieldInfo
MemberInfo
MethodInfo
ParameterInfo
TypeInfo