我有一个非常简单的场景:“人”可以是公司的“客户”或“员工”.
可以通过电话使用“呼叫”方法呼叫“人”.
取决于“人”在呼叫的上下文中扮演的角色,例如新产品的公告或组织变更的公告,我们应该使用为“客户”角色提供的电话号码或为“员工”角色提供的电话号码.
以下是对情况的总结:
interface IPerson { void Call(); } interface ICustomer : IPerson { } interface IEmployee : IPerson { } class Both : ICustomer,IEmployee { void ICustomer.Call() { // Call to external phone number } void IEmployee.Call() { // Call to internal phone number } }
error CS0539: 'ICustomer.Call' in explicit interface declaration is not a member of interface error CS0539: 'IEmployee.Call' in explicit interface declaration is not a member of interface error CS0535: 'Both' does not implement interface member 'IPerson.Call()'
这种情况是否有机会以不同的方式在C#中实现,还是我必须找到另一种设计?
如果是这样,你建议用什么替代品?
在此先感谢您的帮助.
解决方法
原文地址:https://www.jb51.cc/csharp/91924.html
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。