简体   繁体   English

接口实现者对象的命名约定

[英]Naming convention for interface implementator's object

What is the most commonly used convention (in C# and VB) to name object, when I want to emphesize that it is an instance of class that implements some interface. 当我想强调它是实现某些接口的类的实例时,最常用的命名约定(在C#和VB中)是什么。 Like here: 像这儿:

//is iDisp correct name?
protected void Dispose(IDisposable iDisp)
{ 
    iDisp.Dispose();
    Console.WriteLine("Disposed");
}

我从接口名称中删除I,然后驼峰式命名其余名称,因此对于您的示例,我将其称为一次性使用。

I would not use the name iDisp , but rather name the variable disposable . 我不会使用iDisp这个名字,而是将其命名为disposable变量。

Since the interface name should describe a function/protocol that should be implemented, the name disposable tells that the object implements this function. 由于接口名称应描述应实现的功能/协议,因此disposable名称表示对象实现了该功能。

I dont think is there any naming convection for this. 我认为对此没有任何命名对流。 If I were you I just use the name: disposable or d 如果我是你,我只用名字:一次性或d

可以找到Microsoft的命名准则-> 在这里 <-

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM