问题描述
C#常量的命名约定?
我们对什么是更好的以及更常见的使用
有轻微争议?
(更好=很容易看到常量,很好看的代码和大多数
与其他人正在做的一致)
应该是
private const string InternalCode =" ABC";
或
private const string _internal_code =" ABC";
或
private const string INTERNAL_CODE =" ABC";
欢迎所有想法
Sam Martin
naming conventions for C# constants?
we''re having a mild dispute as to what is better and what is more commonly
used?
(better = easy to see as constant, nice to look at in code and most
consistant with what everyone else is doing)
should it be
private const string InternalCode = "ABC";
or
private const string _internal_code = "ABC";
or
private const string INTERNAL_CODE = "ABC";
all ideas welcome
Sam Martin
推荐答案
我最喜欢的编码标准是用私有成员变量加前缀
下划线。似乎传统的常量标准是ALL
CAPS,由下划线分隔的术语。将两者结合起来:
private const _INTERNAL_CODE =" ABC" ;;
只是我的
My favored coding standard is to prefix private member variables with an
underscore. It also seems that the traditional standard for constants is ALL
CAPS, terms seperated by underscores. Combining the two you would have:
private const _INTERNAL_CODE = "ABC";
Just my
这篇关于继承人很容易...的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!