コード例 #1
0
    public static PooType StronglyTypedExcrement <PooType>(this IPooProvider <PooType> iPooProvider)
        where PooType : Poo
    {
        BaseAnimal animal = (BaseAnimal)iPooProvider;

        return((PooType)animal.Excrement);
    }
コード例 #2
0
    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);
    }