Apparently, extension methods don't work on subclasses, or is it just me?
private class Parent
{
}
private class Child
{
}
public static class Extensions
{
public static void Method(this Parent parent)
{
}
}
//Test code
var p = new Parent();
p.Method(); // <--- compiler like
var c = new Child();
c.Method(); // <--- compiler no like
UPDATE
There is a typo in this question (which I'm leaving so that the rest makes sense) - I forgot to make Child
inherit from Parent
.
As it happens, my real problem was that I didn't have the appropriate using
statement.
(Unfortunately, I can't delete, as too many upvotes on answer.)