Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Interface with base class
Message
General information
Forum:
ASP.NET
Category:
Object Oriented Programming
Environment versions
Environment:
C# 3.0
Miscellaneous
Thread ID:
01416072
Message ID:
01416621
Views:
61
Hi Viv,

> I don't see why not - AFAICS no strong-typing rules are being broken.

But they are...
Test x = new Test();
ITest y = (ITest) x;
x.Parent.MethodOfDerivedClass();
y.Parent.MethodOfDerivedClass();
The first method call of MethodOfDerivedClass() would need to work since x.Parent is defined as being of type DerivedClass. The second method call would fail, though, because the interface returns the base class. In both cases, however, the code calls exactly the same Parent getter because the interface is implemented implicitly. So, you have the same method but two signatures. If that doesn't violate strong typing, I don't know what else would... The compiler can't do an implicit cast here.
--
Christof
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform