每当我编写一个新类并添加一些内部字段时,我都会使用下划线前缀,如下所示:
private readonly int _foo;
为什么 .NET 团队决定创建一个名为 _AppDomain 的 AppDomain 接口(interface)?每当我键入下划线以在智能感知中获取我的类级别字段时,看到它只会让我感到烦恼。为什么不是 IAppDomain 或其他东西?
是的,我很挑剔……我知道
最佳答案
该接口(interface)存在for this purpose:
Exposes the public members of the
System.AppDomain
class to unmanaged code. This API is not CLS-compliant.
因此,我认为这种类型有更宽松的命名约定。虽然很难说为什么这样做,但该类型肯定不符合框架设计指南。
关于c# - 为什么 _AppDomain 的前缀是下划线?说真的,这让我很烦恼,它总是在我的领域 intellisense,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2463650/