What is the universally accepted naming convention for c#? (functions, classes, parameters, local variables, namespaces, etc)
Naming Conventions rules for Variables and Methods (Functions) are: It should begin with an alphabet. There may be more than one alphabet, but without any spaces between them. Digits may be used but only after alphabet. No special symbol can be used except the underscore (_) symbol.
Classic C doesn't use camel-case; I've written code in camel-case in C, and it looks weird (so I don't do it like that any more). That said, it isn't wrong - and consistency is more important than which convention is used.
What Does Naming Convention Mean? Naming conventions are general rules applied when creating text scripts for software programming. They have many different purposes, such as adding clarity and uniformity to scripts, readability for third-party applications, and functionality in certain languages and applications.
A variable name must start with a letter or an underscore character (_) A variable name cannot start with a digit. A variable name can only contain alpha-numeric characters and underscores ( a-z, A-Z , 0-9 , and _ ) Variable names are case-sensitive (age, Age and AGE are three different variables)
Microsoft has an excellent set of guidelines on class library design, including a section on naming. In short (examples in parentheses):
WebRequest
)IDisposable
)ToUpper
)Length
)Click
)System.Collections
; unusual to have two words in one part though)keySelector
)Int32.MaxValue
)HttpStatusCode
, BindingFlags
)ThreadStaticAttribute
)Private names are up to you, but I tend to follow the same conventions as for everything else. Hungarian notation (in the style of Win32) is discouraged, although many places use "m_" or "_" as a prefix for instance variables.
Resharper's guidelines suggest
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With