System.Type.MakeGenericType C# (CSharp) Method

MakeGenericType() public method

Substitutes the elements of an array of types for the type parameters of the current generic type definition and returns a T:System.Type object representing the resulting constructed type.
The current type does not represent a generic type definition. That is, returns false. is null.-or- Any element of is null. The number of elements in is not the same as the number of type parameters in the current generic type definition.-or- Any element of does not satisfy the constraints specified for the corresponding type parameter of the current generic type. -or- contains an element that is a pointer type ( returns true), a by-ref type ( returns true), or . The invoked method is not supported in the base class. Derived classes must provide an implementation.
public MakeGenericType ( ) : Type
return Type
        public virtual Type MakeGenericType(params Type[] typeArguments)
        {
            return _GetTypeFromTypeFunc(SpecialFunctions.MakeGenericTypeFactory(thisType, typeArguments.Select(x => x.thisType).ToArray().As<JsArray>()));
        }

Usage Example

Ejemplo n.º 1
0
 internal static Expression NewExpr(this Type baseType, Type ifInterfaceType)
 {
     var newExpr = baseType.IsInterface()
         ? New(ifInterfaceType.MakeGenericType(TypeHelper.GetElementTypes(baseType, ElemntTypeFlags.BreakKeyValuePair)))
         : DelegateFactory.GenerateConstructorExpression(baseType);
     return ToType(newExpr, baseType);
 }
All Usage Examples Of System.Type::MakeGenericType