gpt4 book ai didi

c# - 常量首字母缩略词的命名约定

转载 作者:太空宇宙 更新时间:2023-11-03 19:02:17 25 4
gpt4 key购买 nike

根据 StyleCop,常量的命名约定是 Pascal。

例如

private const double InchToMm= 2.54;

首字母缩略词的命名约定如何?

private const int Dpi = 96;

private const int DPI = 96;

最佳答案

Microsoft 的 Framework Design Guidelines 说:

The PascalCasing convention, used for all identifiers except parameter names, capitalizes the first character of each word (including acronyms over two letters in length), as shown in the following examples:

PropertyDescriptor

HtmlTag

A special case is made for two-letter acronyms in which both letters are capitalized, as shown in the following identifier:

IOStream

The camelCasing convention, used only for parameter names, capitalizes the first character of each word except the first word, as shown in the following examples. As the examples also shows, two-letter acronyms that begin a camel-cased identifier are both lowercase:

propertyDescriptor

ioStream

htmlTag

但是,这些只是指导方针和惯例,而不是法律。如果您想采用其他约定,请使用它。但是永远不要混淆。

关于c# - 常量首字母缩略词的命名约定,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34181163/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com