C# naming conventions for acronyms

前端 未结 8 2038
耶瑟儿~
耶瑟儿~ 2020-12-04 09:55

Regarding C# naming for acronyms, if I was writing a library related to the Windows API is there any strong convention toward either WindowsApi or WindowsAPI or is it just p

相关标签:
8条回答
  • 2020-12-04 10:22

    Check Microsoft's official docs on Naming Guidelines & Capitalization Conventions:

    To differentiate words in an identifier, capitalize the first letter of each word in the identifier. Do not use underscores to differentiate words, or for that matter, anywhere in identifiers. There are two appropriate ways to capitalize identifiers, depending on the use of the identifier:

    • PascalCasing
    • camelCasing

    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 example also shows, two-letter acronyms that begin a camel-cased identifier are both lowercase.

    • propertyDescriptor
    • ioStream
    • htmlTag

    ✓ DO use PascalCasing for all public member, type, and namespace names consisting of multiple words.

    ✓ DO use camelCasing for parameter names.

    0 讨论(0)
  • 2020-12-04 10:23

    There is a convention, and it specifies initial uppercase, the rest lowercase, for all acronyms that are more than 2 characters long. Hence HttpContext and ClientID.

    0 讨论(0)
提交回复
热议问题