Wie rufe ich eine generische Erweiterungsmethode mit Reflektion auf?

Ich habe die Erweiterungsmethode geschriebenGenericExtension. Jetzt möchte ich die Erweiterungsmethode aufrufenExtension. Aber der Wert vonmethodInfo ist immer null.

public static class MyClass
{
    public static void GenericExtension<T>(this Form a, string b) where T : Form
    {
        // code...
    }

    public static void Extension(this Form a, string b, Type c)
    {
        MethodInfo methodInfo = typeof(Form).GetMethod("GenericExtension", new[] { typeof(string) });
        MethodInfo methodInfoGeneric = methodInfo.MakeGenericMethod(new[] { c });
        methodInfoGeneric.Invoke(a, new object[] { a, b });
    }

    private static void Main(string[] args)
    {
        new Form().Extension("", typeof (int));
    }
}

Was ist falsch?

Antworten auf die Frage(4)

Ihre Antwort auf die Frage