From MS official guideline:
1 We Use the Allman style braces, where each brace begins to a new line.
while (x = = y) { something (); SomethingElse ();} Finalthing ();
2 We use four spaces of indentation (no tabs).
3 We Use the CamelCase for internal and private fields and the use readonly where possible. Prefix instance fields with, the static fields with S_ and the thread static fields with T_. When used in static fields, ReadOnly should come after static (i.e. static readonly not readonly static).
4 We Avoid this. Unless absolutely necessary.
5 We always specify the visibility, even if it ' s the default. Visibility should be the first modifier.
private string _foo//betterstring _foo //bad
Public abstract//betterabstract Public//bad
6 Namespace Imports should is specified at the top of the file, outside of Namespace declarations and should be sorted ALP Habetically.
Using System.io;using system.collections;namespace CAXA. Mes. Ui. performance.board{public class LinkedList { }}
7 Avoid more than one empty line at any time. For example, does not has a lines between members of a type.
8 Avoid spurious free spaces.
if (Somevar = = 0) ...,
9 If A file happens to differ on style from these guidelines (e.g. private members is named M_member rather than _member) The existing style in that file takes precedence.
We only use Var when it's obvious what's the variable type is.
var stream = new FileStream (...)//var is Okayvar stream = Openstandardinput ()//This is not good
We use language keywords instead of BCL types.
int, string, float//Good Int32, String, single/Bad
We use the pascalcasing to name all our constant local variables and fields. The only exception are for interop code where the constant value should exactly match the name and value of the code you AR E calling via Interop.
Private Const int age=100; Good
We use nameof(...) instead of "..." whenever possible and relevant.
Should is specified at the top within type declarations.
When including non-ascii characters in the source code use Unicode escape sequences (\uxxxx) instead of literal char Acters.