Why is the base class being called?
Posted
by oneBelizean
on Stack Overflow
See other posts from Stack Overflow
or by oneBelizean
Published on 2010-04-30T18:04:04Z
Indexed on
2010/04/30
18:07 UTC
Read the original article
Hit count: 245
c#
|polymorphism
I'm new to c# so bare with me. But here's my situation.
interface Icontainer{
string name();
}
abstract class fuzzyContainer : Icontainer{
string name(){
return "Fuzzy Container";
}
}
class specialContainer: fuzzyContainer{
string name(){
return base.name() + " Special Container";
}
}
Icontainer cont = new SpecialContainer();
cont.name(); // I expected "Fuzzy Container Special Container" as the output.
When I run my code as described above the output is simply "Fuzzy Container". What am i missing here? Is there a better way to get the desired results?
© Stack Overflow or respective owner