public static IntPtr MakeGenericType(Type type, Type[] typeArgs)
{
if (type == null)
throw new ArgumentNullException("type");
if (typeArgs == null)
throw new ArgumentNullException("typeArgs");
if (!type.IsGenericTypeDefinition)
throw new ArgumentException("Type is not a generic type definition (e.g. List`1)", "type");
var typeParams = type.GetGenericArguments();
if (typeParams.Length != typeArgs.Length)
throw new ArgumentException("An invalid amount of type arguments was specified", "typeArgs");
return type.MakeGenericType(typeArgs).TypeHandle.Value;
}