Skip to content
Discussion options

You must be logged in to vote

Generic extension methods on generic extensions have the combination of the generic type parameters between the two declarations, so:

public static class ExtensionMembers {
    extension<T>(Base<T> This) {
        public void GenericTest<TOther>() {
            Console.WriteLine("TOther");
        }
    }
}

// must be called like this:

Base<int> b = ...;
b.GenericTest<int, string>();

This was already the case with extension methods, but more obvious given the way they are declared:

public static class ExtensionMembers {
    public static void GenericTest<T, TOther>(this Base<T> This) {
        Console.WriteLine("TOther");
    }
}

Replies: 1 comment 2 replies

Comment options

You must be logged in to vote
2 replies
@TonyValenti
Comment options

@jnm2
Comment options

jnm2 Sep 10, 2025
Collaborator

Answer selected by jnm2
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
3 participants