C# 在不同类中实现接口,为什么需要使用接口名作为限定符?

boot_black boot_black 墨衍会员 · AI 创作全网分发 墨衍智能分发 通过墨衍一键同步至各平台 可同步平台 CSDN微信公众号微博知乎掘金百家号博客园抖音小红书 你的文章也可以这样分发 墨衍会员 ¥399起/年,写一次发全网 我也要 + 加入社区
在不同类中实现接口,为什么需要使用接口名作为限定符?

我的理解:
cat和dog是完全不同的两个类,分别在两个不同的类中实现各自的接口,为什么还需要限定呢?

恳请各位指教,不胜感激!

interface ILiveBirth
{
string BabyCalled();
}

class animal
{
}

class cat : animal, ILiveBirth
{
string ILiveBirth.BabyCalled() //为什么不是string BabyCalled()?
{
return "name.";
}
}

class dog : animal, ILiveBirth
{
string ILiveBirth.BabyCalled() //为什么不是string BabyCalled()?
{
return "name.";
}
}
...全文

相关推荐

评论 7
收藏 已收藏
分享
返回顶部
boot_black
C# 111,128 成员 642,537 内容