c# - 为什么我们不允许在接口(interface)中指定构造函数?

标签 c# .net vb.net oop

<分区>

Possible Duplicate:
Interface defining a constructor signature?

我知道您不能在 .Net 的接口(interface)中指定构造函数,但为什么我们不能呢?

如果能够指定“引擎”必须与构造函数一起传入,这对我当前的项目非常有用,但由于我不能,我必须对类进行 XML 注释。

最佳答案

因为接口(interface)描述了行为。构造函数不是行为。如何构建对象是一个实现细节。

关于c# - 为什么我们不允许在接口(interface)中指定构造函数?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/689474/

相关文章:

.net - PowerShell 找不到 .NET 框架

c# - 为什么 NamespaceManager 在 XPath 中不使用前缀时不使用 DefaultNamespace

c# - 一般委托(delegate)类型错误

c# - 下拉箭头的宽度

c# - 在 Google Tile Server 中平铺(x、y 和 z 参数)

c# - 如何在 EF Core 中配置可为空的 1-1 关系?

c# - 在 <p> 标记内渲染时删除冗余空格

c# - 如何在 CentOS 上的 .Net-Core 2 中忽略 SSL 证书验证

asp.net - 使用树节点使当前选择无法再次选择

c# - 保存 chrome cookies Selenium