.net - 为什么 .Net 中的常量不是全部大写?

标签 .net naming-conventions constants

.Net 的 Microsoft 命名约定将常量放在 Pascal Case 中。事实上,它明确告诉我们避免对常量使用全部大写:

You might also have to capitalize identifiers to maintain compatibility with existing, unmanaged symbol schemes, where all uppercase characters are often used for enumerations and constant values. In general, these symbols should not be visible outside of the assembly that uses them.



来自 MSDN .

在 SO 上,我发现了一些有关该主题的问题,例如 one ,但我找不到理由。那么,任何人都知道或有一个引用来说明为什么 MS 选择了这个约定?

最佳答案

它只是一个风格指南。编程语言已经开始推荐和插入格式化约定,以便代码更具可读性。

此外,被预处理器替换的符号值得特别注意——它们存在于类型系统之外/之前,可能与它们看起来的不同。常量只是常量,它们不会在编译或运行时改变。

关于.net - 为什么 .Net 中的常量不是全部大写?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3783003/

相关文章:

c# - 星期几的 DateTimeFormatInfo 字符串格式。周四变成 Th

.net - 使用 System.Security.Cryptography 将 Win32 Crypto API 调用转换为 C#

objective-c - 如何向 Objective-C 项目批量添加 2 个字母的前缀/命名空间?

cocoa - CGGeometry、CGPoint、CGRect中的 "CG"代表什么?

c++ - 如何将数据类型传递给 Win32 C++ 中的资源 (.rc) 文件?

c++ - 在 C++ 中将非 const 转换为 const

c# - List <Type>到C#中的List <Interface>?

c# - 如何使.net winform 应用程序解析友好

java - 没有为使用名称 'redirect-action' 映射的类型 'success' 定义结果类型

c++ - 理解常量