No type inference with generic extension method

UPDATE from November 2020: The original answer below was written in 2011; the rules for generic method type inference, overload resolution, and how “final validation” of methods is done have had small but significant changes in recent versions of C#; this answer, and the link to an archived article on my original MSDN blog about it might no longer be accurate. Also, Microsoft deleted the comments on the original article for legal reasons; there was a huge amount of context and discussion in those comments. I hope to at some point have the time to revisit this article to clarify (1) the rules today, (2) how they have changed, and (3) how the ideas discussed in those deleted comments influenced those decisions, but that’s a lot of work and I may not get to it for some time. Remember, I have not been on the C# language design team since November 2012.


Generic method type inference deliberately does not make any deductions from the constraints. Rather, deductions are made from the arguments and the formal parameters, and then the deduced type arguments are checked against the constraints.

For a detailed discussion of some of the design issues around constraints and method signatures, including several dozen people telling me that I’m wrong to think that the existing design is sensible, see my article on the subject:

https://docs.microsoft.com/en-gb/archive/blogs/ericlippert/constraints-are-not-part-of-the-signature

Leave a Comment