似乎使用 Partial
的优点NotInheritable
Class
是可以在其中声明/实现共享方法。
这是一个代码示例,以帮助可视化问题。
Namespace MyNamespace.Utility
' Cannot Declare Shared Function
Public NotInheritable Class Document
' Can Declare Shared Function
End Class
End Namespace
这是反对
Namespace MyNamespace
Partial Public NotInheritable Class Utility
' Can Declare Shared Function
Partial Public NotInheritable Class Document
' Can Declare Shared Function
End Class
End Class
End Namespace
最佳答案
Utility 应该是一个命名空间,因为它充当一个逻辑分组。
Microsoft .NET Framework Nested Types Guidelines
我不同意您声称密封类的优点是您可以定义静态方法,任何类都可以做到这一点。
关于vb.net - 使用嵌套命名空间而不是部分公共(public) NotInheritable 类是否有优势,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12884144/