Today, when you are developing an application, I will explain to you the Naming Convention of C # Coding Standards for best practice of C# coding.
CamelCase (camelCase): In this (camelCase) the first letter of the word always in small letter and after that each word with capital letter.
Pascal Case (PascalCase): In this (PascalCase) the first letter of every word is in capital letter.
Underscore Prefix (_underscore): For underscore (_), the word after _ use camelCase term.
Always use native datatype instead of .NET. Example, use int instead of Int16 or Int32.
Do not use the short form. Use the name, address, salary etc. instead of nam, addr, sal.
Do not use single character variable names like a, b, c, etc. Use names like index and temp.
Do not use underscores (_) in variable names.
Namespace names should follow the standard pattern.
According to my own definition, the following are the characteristics of the code.
Here the naming conferences, coding standards and the best practices described in this document have been compiled by our own experience and by mentioning various Microsoft and non-Microsoft guidelines.
Purpose of coding standards and best practices
To develop a reliable and maintainable application, you must be follow coding standards and best practices.
The naming conventions or coding standards and best practices described in this document are compiled from my own experience and by referring to various Microsoft and non-Microsoft guidelines.
There are various standards exists in the programming area. None of them is wrong or bad and you can follow the code of any of them.
And most importantly, you choose a standard approach and also ensure that everyone is following it.
Always use PascalCase for a namespace.
Always use PascalCase for method names. The maximum 7 parameters for the method should be used.
Note: Don't use a name as all character in CAPS.
Always use PascalCase for class names. Try to use a noun or noun phrase for a class name.
Arguments and Local Variable
We should always use camelCase for method arguments and local variables. we should not use Hungarian notation for any variables.
Note: Don't use the short form for any words and don't use an underscore (_) in between any name.
Use PascalCase for the property. Never use Get and Set as a prefix with the property name.
Always use the letter "I" as a prefix with the name of an interface. After letter I, use PascalCase.
Private Member Variable
Always try to use camelCase terminology prefix with an underscore ( _ )
Declare member variable at the top of the class, if the class has static member then it will come at the topmost and after that other member variable.
Always use a singular noun to define Enum.
Today we learned coding standard naming conventions in C#. Thanks for reading this article, hope you enjoyed it.