C# 接口(interface)返回类型

标签 c# interface

我有几个接口(interface),IOrganisations 和 IPeople。

如果我想返回与组织关联的人员列表,我应该在哪个界面中创建它?

结果基于组织,但我返回的是的列表

最佳答案

IOrganisation 上执行(并将 IPeople 作为返回类型)。

像这样:

interface IOrganisation {
    IList<IPeople> GetPeople();
}

这是因为组织的人员是组织的属性(property),而不是人员的属性(property)。

关于C# 接口(interface)返回类型,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7674950/

相关文章:

c# - 使用 C# 在 MSCharts 中快速绘图

c# - 隐藏具有关联属性的输入标签

javascript - 如何记录对象的契约(Contract)

android - Android 设备对压力敏感度的支持程度如何?

c# - System.Data.IDbCommand 和异步执行?

c# - Microsoft Graph API 不返回我需要的属性

c# - 队列如何与 foreach 循环交互

c# - 将证书作为嵌入资源加载到程序集中

c# - C#中的替代内联接口(interface)实现

typescript - TypeScript 中的接口(interface)与类型