public static PooType StronglyTypedExcrement <PooType>(this IPooProvider <PooType> iPooProvider) where PooType : Poo { BaseAnimal animal = (BaseAnimal)iPooProvider; return((PooType)animal.Excrement); }
public static PooType StronglyTypedExcrement <PooType>( this IPooProvider <PooType> iPooProvider) where PooType : Poo { BaseAnimal animal = iPooProvider as BaseAnimal; if (null == animal) { throw new InvalidArgumentException("iPooProvider must be a BaseAnimal."); } return((PooType)animal.Excrement); }