标签: .net c# programming-c#-5-0
1235人阅读 评论(0) 收藏 举报

文献:msdn library
平台:.NET 2.0+

from ms official guideline:

1 We use Allman style braces, where each brace begins on a new line.

while (x == y)


2 We use four spaces of indentation (no tabs).

3 We use camelCase for internal and private fields and use readonly where possible. Prefix instance fields with , static fields with s_ and thread static fields with t_. When used on 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 //better
string _foo  //bad
public abstract //better
abstract public //bad

6 Namespace imports should be specified at the top of the file, outside of namespace declarations and should be sorted alphabetically.

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, do not have two blank lines between members of a type.

8 Avoid spurious free spaces.

if (someVar == 0)..., 

9 If a file happens to differ in style from these guidelines (e.g. private members are named m_member rather than _member), the existing style in that file takes precedence.

10 We only use var when it’s obvious what the variable type is.

var stream = new FileStream(...) //var is OKay
var stream = OpenStandardInput() // here var is not good

11 We use language keywords instead of BCL types.

 int, string, float // good
 Int32, String, Single // bad

12 We use PascalCasing to name all our constant local variables and fields. The only exception is for interop code where the constant value should exactly match the name and value of the code you are calling via interop.

private const int Age=100; //good

13 We use nameof(…) instead of “…” whenever possible and relevant.

14 Fields should be specified at the top within type declarations.

15 When including non-ASCII characters in the source code use Unicode escape sequences (\uXXXX) instead of literal characters.



  • 2012年09月19日 12:28
  • 353KB
  • 下载


散弹枪编程 这种编程风格是一种开发者使用非常随意的方式对待代码。“嗯,这个方法调用出错了……那么我会试着把传出的参数从 false 变成 true!”,当然依然出错,于是我们的程序员会这样:“好吧...
  • u014805066
  • u014805066
  • 2017-03-22 09:32:08
  • 479


  • 2010年10月11日 15:44
  • 508KB
  • 下载

微软官方 .NET 指南 20171224

  • 2017年12月24日 17:37
  • 10.81MB
  • 下载

Microsoft Orleans框架

Orleans is a framework that provides a straightforward approach to building distributed high-scale c...
  • silentrock
  • silentrock
  • 2016-03-03 11:40:44
  • 5123

微软官方 C# 指南 20171224

  • 2017年12月24日 16:37
  • 3.18MB
  • 下载

微软官方 .NET Core 指南 20171224

  • 2017年12月24日 17:50
  • 3.32MB
  • 下载

Google C++编程风格指南

GoogleC++编程风格指南 译者前言 Google经常会发布一些开源项目,意味着会接受来自其他代码贡献者的代码;但是如果代码贡献者的编程风格与Google的不一致,会给代码阅读者和其他代码提交这造...
  • gdutliuyun827
  • gdutliuyun827
  • 2013-12-15 23:15:33
  • 1782


  • 2014年03月01日 13:21
  • 49.56MB
  • 下载


  • 2017年11月20日 20:26
  • 31.2MB
  • 下载

    交流思想,注重分析,实例阐述,通俗易懂,包含但不限于:经典算法,机器学习,深度学习,LeetCode 题解,Kaggle 实战。期待您的到来!


    专栏达人 持之以恒
    访问量: 33万+
    积分: 7788
    排名: 3400