System.Reflection.RuntimeMethodInfo.MakeGenericMethod C# (CSharp) Method

MakeGenericMethod() public method

public MakeGenericMethod ( ) : MethodInfo
return MethodInfo
        public override MethodInfo MakeGenericMethod(params Type[] methodInstantiation)
        {
          if (methodInstantiation == null)
                throw new ArgumentNullException("methodInstantiation");

            Type[] methodInstantiationCopy = new Type[methodInstantiation.Length];
            for (int i = 0; i < methodInstantiation.Length; i ++)
                methodInstantiationCopy[i] = methodInstantiation[i];
            methodInstantiation = methodInstantiationCopy;

            if (!IsGenericMethodDefinition)
                throw new InvalidOperationException(
                    String.Format(CultureInfo.CurrentCulture, Environment.GetResourceString("Arg_NotGenericMethodDefinition"), this));

            for (int i = 0; i < methodInstantiation.Length; i++)
            {
                if (methodInstantiation[i] == null)
                    throw new ArgumentNullException();
            
                if (!(methodInstantiation[i] is RuntimeType))
                    return MethodBuilderInstantiation.MakeGenericMethod(this, methodInstantiation);
            }

            Type[] genericParameters = GetGenericArguments();

            RuntimeType.SanityCheckGenericArguments(methodInstantiation, genericParameters);

            RuntimeTypeHandle[] typeHandles = new RuntimeTypeHandle[methodInstantiation.Length];

            for(int i = 0; i < methodInstantiation.Length; i++) 
                typeHandles[i] = methodInstantiation[i].GetTypeHandleInternal();

            MethodInfo ret = null;
                
            try
            {
                ret = RuntimeType.GetMethodBase(m_reflectedTypeCache.RuntimeTypeHandle, 
                    m_handle.GetInstantiatingStub(m_declaringType.GetTypeHandleInternal(), typeHandles)) as MethodInfo;
            }
            catch (VerificationException e)
            {
                RuntimeType.ValidateGenericArguments(this, methodInstantiation, e);
                throw e;
            }
            
            return ret;
        }