What causes “extension methods cannot be dynamically dispatched” here?

So, can somebody please help me understand why leveraging the same overload inside of those other methods is failing with that error? Precisely because you’re using a dynamic value (param) as one of the arguments. That means it will use dynamic dispatch… but dynamic dispatch isn’t supported for extension methods. The solution is simple though: … Read more

Extension method priority

When the compiler searches for extension methods, it starts with those declared in classes in the same namespace as the calling code, then works outwards until it reaches the global namespace. So if your code is in namespace Foo.Bar.Baz, it will first search Foo.Bar.Baz, then Foo.Bar, then Foo, then the global namespace. It will stop … Read more

Why doesn’t VS 2008 display extension methods in Intellisense for String class

It’s by explicit design. The problem is that while String most definitely implements IEnumerable<T>, most people don’t think of it, or more importantly use it, in that way. String has a fairly small number of methods. Initially we did not filter extension methods off of String and the result was a lot of negative feedback. … Read more

Resolving extension methods/LINQ ambiguity

This is probably one of those rare cases where it makes sense to use an extern alias. In the properties page for the reference to System.Core (i.e. under References, select System.Core, right-click and select “Properties”), change the “Aliases” value to “global,SystemCore” (or just “SystemCore” if it’s blank to start with). Then in your code, write: … Read more