Redian新闻
>
Question about Explicit interface members in c#
avatar
Question about Explicit interface members in c## DotNet - 窗口里的风景
s*k
1
why does C# offer this feature?
For a class implementing a interface, the purpose is to make this class have
both features of the class itself and of the interface it implemnts.
"Explicit interface members" enforces the call from interface's level, why?
why? why?
Thanks for comments.
avatar
d*r
2
Explicit interface member has two usage:
1. Hide the implementation of interface member
2. Solve ambiguity of inheritance from two interfaces with the same member
name.

【在 s*******k 的大作中提到】
: why does C# offer this feature?
: For a class implementing a interface, the purpose is to make this class have
: both features of the class itself and of the interface it implemnts.
: "Explicit interface members" enforces the call from interface's level, why?
: why? why?
: Thanks for comments.

avatar
s*k
3
Thanks 大米.
Further about the usage 1:
Why do we need to hide the implementation of interface members in the first
place? For instance?
Advanced thanks.

【在 d*r 的大作中提到】
: Explicit interface member has two usage:
: 1. Hide the implementation of interface member
: 2. Solve ambiguity of inheritance from two interfaces with the same member
: name.

avatar
d*r
4
This is a design issue and very hard to say if it is appropriate or not.
And by this way, you can access the member through interface declaration but
not through class declaration.

【在 s*******k 的大作中提到】
: Thanks 大米.
: Further about the usage 1:
: Why do we need to hide the implementation of interface members in the first
: place? For instance?
: Advanced thanks.

avatar
k*i
5
check Juval Lowy's book

【在 s*******k 的大作中提到】
: why does C# offer this feature?
: For a class implementing a interface, the purpose is to make this class have
: both features of the class itself and of the interface it implemnts.
: "Explicit interface members" enforces the call from interface's level, why?
: why? why?
: Thanks for comments.

avatar
s*k
6
A way to enforce upcasting, which sometimes is a good practice. What else?
It is, in some sense, powerful to be able to distinguish methods with the
identical signature from different parent interfaces. Most OO languages can't
handle this situation, except in programmable manner.
However, this situation itself, seems to me a flaw. Covering a flaw is not
positive features a programming language should offer.

【在 s*******k 的大作中提到】
: Thanks 大米.
: Further about the usage 1:
: Why do we need to hide the implementation of interface members in the first
: place? For instance?
: Advanced thanks.

相关阅读
logo
联系我们隐私协议©2024 redian.news
Redian新闻
Redian.news刊载任何文章,不代表同意其说法或描述,仅为提供更多信息,也不构成任何建议。文章信息的合法性及真实性由其作者负责,与Redian.news及其运营公司无关。欢迎投稿,如发现稿件侵权,或作者不愿在本网发表文章,请版权拥有者通知本网处理。