S
Steve W.
I just read the section (and did the exercise) in the C#
Step by Step book that covers Explict Interface
Implementation (where you specify in the method
implementation the specific interface that you are
implementing in the class.
Other than to resolve the problem that arises when a class
implements two interfaces with the same method signature,
what good is it?
The book says that using EII makes the method effectively
private to the class, but the example cited doesn't agree
with the sample program provided. The example says that a
method, once implemented using the "explicit" syntax must
be called using a cast.
IdentifierToken token = new IdentifierToken();
token.Accept(visitor); // won't complile Accept not
accessible
instead...
((IVisitable)token).Accept(visitor); // major tacky
IdentifierToken implements the IVisitable interface (which
includes Accept() ) using the explicit syntax...
IVisitable.Accept(IVisitor visitor) not...
Public Accept(IVisitor visitor)
However the sample program has explicitly implemented
methods, and no cast is used to call them.
So what is EII good for and how does it work?
Step by Step book that covers Explict Interface
Implementation (where you specify in the method
implementation the specific interface that you are
implementing in the class.
Other than to resolve the problem that arises when a class
implements two interfaces with the same method signature,
what good is it?
The book says that using EII makes the method effectively
private to the class, but the example cited doesn't agree
with the sample program provided. The example says that a
method, once implemented using the "explicit" syntax must
be called using a cast.
IdentifierToken token = new IdentifierToken();
token.Accept(visitor); // won't complile Accept not
accessible
instead...
((IVisitable)token).Accept(visitor); // major tacky
IdentifierToken implements the IVisitable interface (which
includes Accept() ) using the explicit syntax...
IVisitable.Accept(IVisitor visitor) not...
Public Accept(IVisitor visitor)
However the sample program has explicitly implemented
methods, and no cast is used to call them.
So what is EII good for and how does it work?