C# Type ContainsGenericParameters
Description
Type ContainsGenericParameters
gets a value indicating
whether the current Type object has type parameters that have not been replaced
by specific types.
Syntax
Type.ContainsGenericParameters
has the following syntax.
public virtual bool ContainsGenericParameters { get; }
Example
The following example defines a generic class with two type parameters and then defines a second generic class that derives from the first class.
//from www .ja v a2 s.c o m
using System;
using System.Reflection;
using System.Collections.Generic;
public class Base<T, U> { }
public class Derived<V> : Base<int, V> { }
public class Test
{
public static void Main()
{
Type derivedType = typeof(Derived<>);
DisplayGenericTypeInfo(derivedType);
// Display its open constructed base type.
DisplayGenericTypeInfo(derivedType.BaseType);
}
private static void DisplayGenericTypeInfo(Type t)
{
Console.WriteLine(t);
Console.WriteLine(t.IsGenericTypeDefinition);
Console.WriteLine(t.IsGenericType);
Console.WriteLine(t.ContainsGenericParameters);
}
}
The code above generates the following result.