Original Post
Hello! I was wondering if there is any way of doing the following in c# : I mean, why can't I let getObj() return DerivedObj instead of BaseObj?? I mean, it should be implicitly cast to a BaseObj? This works in java. I would rather not have to add another function getDerivedObj(), thats just plain ugly :(
interface BaseObj {}
interface Base {
BaseObj getObj();
}
class DerivedObj : Base {}
class Derived : Base {
public DerivedObj getObj() {//...}
public void doSomething(BaseObj base) {}
public void doSomething(DerivedObj derived) {}
}