Suppose the HouseBoat class implements the IHouse interface implicitly and the IBoat interface explicitly. Which of the following statements is false?
a . The code can use a HouseBoat object to access its IHouse members.
b . The code can use a HouseBoat object to access its IBoat members.
c . The code can treat a HouseBoat object as an IHouse to access its IHouse members.
d . The code can treat a HouseBoat object as an IBoat to access its IBoat members.
For this question, The HouseBoat Class will firstly-implicitly implement the IHouse interface. Then It inherits secondly-explicitly the IBoat interface.
- The c and d options are obiviously correct.
- the a option is correct.
So the remained option is b is false. This could explain that the C# team is not to encourage using explicit implementation. To use a HouseBoat object accessing its IBoat member, we must cast the HouseBoat to IBoat. For example:
HouseBoat x=new HouseBoat();
IBoat x= (IBoat)x;
0 comments:
Post a Comment