代码之家  ›  专栏  ›  技术社区  ›  Prescott

部分类和接口

  •  0
  • Prescott  · 技术社区  · 14 年前

    假设我有以下设置:

    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页

    1 回复  |  直到 14 年前
        1
  •  2
  •   Hans Passant    14 年前

    生成的文件需要使用Implements关键字。在VB.NET语言中,这是一个硬性要求,没有解决方法。否则与部分类无关。