【问题标题】:Partial Classes and Interfaces部分类和接口
【发布时间】:2010-11-23 15:28:50
【问题描述】:

假设我有以下设置:

Public Interface IA
    Property Name()
    Property Id()
...
End Interface

//Custom File
Partial Public Class A
... Mostly Blank - used for extending the generated file
End Class

//Generated via a tool
Partial Public Class A
... contains properties, methods, etc
    Property Name() ..
    Property Id() ..
End Class

我已将接口添加到自定义文件中,但 VS 向我抛出了一个错误,因为属性是在生成的文件中实现的。还有其他解决方案吗?我想避免接触生成的部分类。

谢谢, ~P

【问题讨论】:

  • 哪个类实现了接口?从你的问题中不清楚..
  • 自定义文件(没有实际实现属性的那个)

标签: .net inheritance partial-classes


【解决方案1】:

生成的文件需要使用Implements关键字。 VB.NET 语言中的硬性要求,没有解决方法。这与部分类没有任何关系。

【讨论】:

  • C#有同样的限制吗?
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2019-06-26
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2015-01-05
相关资源
最近更新 更多