using System;
using System.Reflection;
public class MyClass {
public T membera;
}
public class XClass {
public void MethodA() {
}
}
class Starter {
static void Main() {
Type[] types = { typeof(MyClass<,>), typeof(MyClass) };
bool[,] bresp = { {types[0].IsGenericType,
types[0].IsGenericTypeDefinition},
{types[1].IsGenericType,
types[1].IsGenericTypeDefinition}};
Console.WriteLine("Is MyClass<,> a generic type? " + bresp[0, 0]);
Console.WriteLine("Is MyClass<,> open? " + bresp[0, 1]);
Console.WriteLine("Is MyClass a generic type? " + bresp[1, 0]);
Console.WriteLine("Is MyClass open? " + bresp[1, 1]);
Type tObj = typeof(XClass);
MethodInfo method = tObj.GetMethod("MethodA");
bool[] bMethod ={method.IsGenericMethod, method.IsGenericMethodDefinition};
Console.WriteLine("Is XClass.MethodA a generic method? " + bMethod[0]);
Console.WriteLine("Is XClass.MethodA open? " + bMethod[1]);
}
}