chaining methods in base and derived class

Viewed 1283

I have 2 classes, one derived from the other:

class Animal
{
    public Animal AnimalMethod() 
    {
        // do something 
        return this; 
    }   
}

class Dog : Animal
{
    public Dog DogMethod()
    {
         // do something
         return this;
    }
}

var dog = new Dog();
dog.DogMethod().AnimalMethod(); // 1 - this works   
dog.AnimalMethod().DogMethod(); // 2 - this doesn't

How can I change my declaration(s) to be able to call the methods in the order "2" above in order to achieve a more fluent api?

3 Answers
Related