C# Coding Style

Indentation

Use 4 spaces, not tabs.

Variable Naming

  • Camel Case, first letter is lower case
  • No abbreviations
  • Instance fields are prefixed with underscore (_)

Object & Method Naming

  • Camel Case, first letter is upper case
  • Methods are verbs
  • Properties/fields are nouns

Visual Studio C# Formatting (go to Tools > Options > Text Editor > C#)

    Tabs
        Tab size: 4
        Indent size: 4
        Insert spaces
    Formatting
        Indentation
            Indent block contents: ON
            Indent open and close braces: OFF
            Indent case contents: ON
            Indent case labels: OFF
            Label indentation: PLAE GOTO LABELS ONE INDENT LESS THAN CURRENT
        New lines
            New line options for braces (ALL OFF)
            New line options for keywords (ALL OFF)
        Spacing
            Set spacing for methods declarations (ALL OFF)
            Set spacing for method calls (ALL OFF)
            Set other spacing options (ALL OFF)
            Set spacing for brackets (ALL OFF)
            Set spacing for delimiters
                Insert space after colon for base or interface in type declaration: ON
                Insert space after comma: ON
                Insert space after dot: OFF
                Insert space after semicolon in "for" statement: ON
                Insert space before colon for base or interface in type declaration: ON
                Insert space before comma: OFF
                Insert space before dot: OFF
                Insert space before semicolon in "for" statement: OF
            Set spacing for operators: INSERT SPACE BEFORE AND AFTER BINARY OPERATORS
        Wrapping
            Leave block on single line: ON
            Leave statement and member declarations on the same line: OFF

Class Organization

Organize class members into these categories in this order using these comments, each preceded by a blank line (omit comment when category has no members)
    //--- Constants ---
    //--- Types ---
    //--- Class Fields ---
    //--- Class Constructor ---
    //--- Class Properties ---
    //--- Class Methods ---
    //--- Fields ---
    //--- Constructors ---
    //--- Properties ---
    //--- Methods ---
    //--- Interface Methods ---

Sort members in each category in this order:
    public
    protected
    protected internal
    internal
    private

Tag page
You must login to post a comment.
Powered by MindTouch Deki Enterprise Edition v.8.08 RC2