关闭

.NET框架-微软C#编程风格官方指南

标签: .netc#programming-c#-5-0
1175人阅读 评论(0) 收藏 举报
分类:

作者:vuefine
文献: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)
{
    something();
    somethingelse();
}

finalthing();

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.

1
0
查看评论

为什么微软的开发人员需要一个风格指南

我通常会从一些读者高射炮,每当我建议软件开发人员可以从微软学习的经验教训。 不是每个人都认为微软是一个榜样。 尽管如此,我仍然坚持,你会捉襟见肘找到另一个微软以外的公司认为更认真,深入的做法和软件开发过程。         ...
  • peng631
  • peng631
  • 2012-02-14 13:38
  • 419

微软.NET代码的编程风格指导规范PDF

  • 2010-10-11 15:44
  • 508KB
  • 下载

终于把Microsoft .NET框架程序设计(修订版)看完了

这本书是由windows & .Net专家Jeffrey Richter写的,现在最新的是第二版CLR Via C#。虽然内容差不了多少,不过俺还是买了。:D。此书由李建忠老师翻译的。   Jeffrey Richter不愧为大师阿,对.NET是相当的了解阿,书写的也是如行云流水...
  • kisserLeon
  • kisserLeon
  • 2006-11-28 19:09
  • 1866

Microsoft.NET框架程序设计(修订版)-中文版.pdf (清晰版)

  • 2014-01-21 20:55
  • 37.66MB
  • 下载

.NET框架程序设计——体系结构

谈到.NET,相信对于大多数初学者而言,都会感觉比较乱、比较迷茫,什么ASP.NET、VB.NET、VC.NET、ADO.NET、.NETFramework 等等概念,搞的我们晕头转向的,他们之间到底是什么关系呢?为何如此相似呢?我们脑子里出现了一堆一堆的问号。下面说一下我自己的理解,不正...
  • dongyue786
  • dongyue786
  • 2014-10-15 15:47
  • 1980

Microsoft .NET框架程序设计.pdf_中文清晰版

  • 2014-01-06 19:51
  • 40.72MB
  • 下载

.net框架程序设计读书笔记二(Microsoft .net 框架开发平台体系架构)

第一章:Microsoft .net 框架开发平台体系架构    本章的目标:对.net框架体系架构有一个总体的认识,并对.net框架中出现的一些新的技术和术语有一个基本的了解。 1.1 将源代码编译为托管模块   关于编程语言的选择...
  • cwbboy
  • cwbboy
  • 2004-05-31 16:57
  • 994

Microsoft .net框架程序设计(修订版)清晰版

  • 2012-12-26 15:50
  • 37.79MB
  • 下载

Microsoft .NET框架程序设计(修订版)

  • 2011-12-01 10:25
  • 20.21MB
  • 下载

microsoft.net框架程序设计(修订版)-中文版

  • 2014-03-11 11:05
  • 19.65MB
  • 下载
    算法channel

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

    算法与人工智能交流群:646901659

    个人资料
    • 访问:320959次
    • 积分:7603
    • 等级:
    • 排名:第3381名
    • 原创:350篇
    • 转载:1篇
    • 译文:0篇
    • 评论:58条
    博客专栏