Generic type instance with reflection

CSharp · Console

/Program.cs

using System;
					
public class Program
{
	public static void Main()
	{
		var integer = typeof(int);
		var nullableInteger =  typeof(int?);
	
		Type generic = typeof(Nullable<>);
		Type genericT = generic.MakeGenericType(integer);
		
		Console.WriteLine(nullableInteger.IsGenericType && nullableInteger ==  genericT);
		
		Type tt = typeof(GenericClass<int>);
		object a = Activator.CreateInstance(tt);
		Console.WriteLine(a);
	
	}
}

public class GenericClass<Int>
{

}
;