C# TypeInfo IsGenericType

Description

TypeInfo IsGenericType Gets a value indicating whether the current type is a generic type.

Syntax

TypeInfo.IsGenericType has the following syntax.


public virtual bool IsGenericType { get; }

Example


using System;// w ww. j a  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