C#命名约定(使用m_varName?) [英] C# naming conventions (is m_varName used?)

查看:117
本文介绍了C#命名约定(使用m_varName?)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

m_variableName是否用于C#类中的数据成员?由于

所有东西都在一个类中,它似乎变得毫无意义。


一般的命名约定是什么?

什么你的个人想法是什么?


我一直在使用m_variableName,但我想我会放弃它。


我'还使用clsMyClassName为类添加前缀,并使用btnOK,btnCancel等具有

frmMyFormName,abd按钮的表单,这些都使得b / b
感觉良好。特别是对于避免姓名冲突的课程。


Zytan

Is the m_variableName used for data members in C# classes? Since
everything is in a class, it seems that it becomes pointless.

What is the general naming conventions?
What are your personal thoughts?

I''ve been using m_variableName, but I think I''m going to drop it.

I''ve also been prefixing classes with clsMyClassName, and forms with
frmMyFormName, abd buttons with btnOK, btnCancel, etc, which all makes
sense. Especially for the classes to avoid name clashes.

Zytan

推荐答案

我喜欢用m_Variable约定,因为它允许我区分成员变量和它的get / set属性。

例如,成员变量可能是m_Name ;,然后我有


公共字符串名称

{

get {return m_Name;}

set {m_Name = Value; ......}

}


加上,旧习惯会变得很难。


Dom

2月28日上午11:47,Zytan < zytanlith ... @ yahoo.comwrote:
I like using the m_Variable convention, because it allows me to
distinguish between a member variable and a get/set property for it.
For example, a member variable might be "m_Name", and then I have

public String Name
{
get {return m_Name;}
set {m_Name = Value; ...}
}

Plus, old habit die hard.

Dom
On Feb 28, 11:47 am, "Zytan" <zytanlith...@yahoo.comwrote:

m_variableName是否用于C#类中的数据成员?由于

所有东西都在一个类中,它似乎变得毫无意义。


一般的命名约定是什么?

什么你的个人想法是什么?


我一直在使用m_variableName,但我想我会放弃它。


我'还使用clsMyClassName为类添加前缀,并使用btnOK,btnCancel等具有

frmMyFormName,abd按钮的表单,这些都使得b / b
感觉良好。特别是对于避免姓名冲突的课程。


Zytan
Is the m_variableName used for data members in C# classes? Since
everything is in a class, it seems that it becomes pointless.

What is the general naming conventions?
What are your personal thoughts?

I''ve been using m_variableName, but I think I''m going to drop it.

I''ve also been prefixing classes with clsMyClassName, and forms with
frmMyFormName, abd buttons with btnOK, btnCancel, etc, which all makes
sense. Especially for the classes to avoid name clashes.

Zytan



m_variableName是否用于C#类中的数据成员?由于
Is the m_variableName used for data members in C# classes? Since

一切都在一个类中,它似乎变得毫无意义。


一般的命名约定是什么?

你有什么个人想法?


我一直在使用m_variableName,但我想我会放弃它。


我也用clsMyClassName为类添加前缀,并用

frmMyFormName,带有btnOK,btnCancel等的abd按钮作为前缀,这些都使得
$ b $感觉。特别是对于避免姓名冲突的班级。
everything is in a class, it seems that it becomes pointless.

What is the general naming conventions?
What are your personal thoughts?

I''ve been using m_variableName, but I think I''m going to drop it.

I''ve also been prefixing classes with clsMyClassName, and forms with
frmMyFormName, abd buttons with btnOK, btnCancel, etc, which all makes
sense. Especially for the classes to avoid name clashes.

http://msdn.microsoft.com/library/en...asp?frame=true


请注意,我对m_上的约定进行了蔑视;然而问题。我更喜欢它

因为它清楚地表明你正在处理一个成员变量。它可以提高易读性IMO,但这是一个宗教问题。

http://msdn.microsoft.com/library/en...asp?frame=true

Note that I flout the conventions on the "m_" issue however. I prefer it
because it clearly indicates you''re dealing with a member variable. It
improves legibility IMO but it''s a religious issue.


我喜欢使用m_Variable约定,因为它允许我
I like using the m_Variable convention, because it allows me to

区分成员变量和它的get / set属性。

例如,成员变量可能是m_Name,然后我有


公共字符串名称

{

get {return m_Name;}

set { m_Name =值; ......}


}


另外,旧习惯会变得很难受。
distinguish between a member variable and a get/set property for it.
For example, a member variable might be "m_Name", and then I have

public String Name
{
get {return m_Name;}
set {m_Name = Value; ...}

}

Plus, old habit die hard.



是的,但你提出了一个好点。谢谢


Zytan

Yup, but you raise a good point. thanks

Zytan


这篇关于C#命名约定(使用m_varName?)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆