.NET框架-微软C#编程风格官方指南
来源:互联网 发布:如何查询淘宝商品类目 编辑:程序博客网 时间:2024/05/18 03:05
作者: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 //betterstring _foo //bad
public abstract //betterabstract 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 OKayvar 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.
- .NET框架-微软C#编程风格官方指南
- 官方 raywenderlich.com Swift 编程风格指南
- 微软官方的C# Socket编程示例
- c# 微软官方手册
- MATLAB 编程风格指南
- LISP编程风格指南
- MATLAB 编程风格指南
- MATLAB 编程风格指南
- Google_C++编程风格指南
- Swift 编程风格指南
- Swift编程风格指南
- MATLAB 编程风格指南
- MATLAB 编程风格指南
- Java编程风格指南
- JavaScript编程风格指南
- javascript编程风格指南
- Pointfree 编程风格指南
- Java编程风格指南
- android官方training课程
- Win10 卸载 Cortana
- 第16题:3Sum Closest
- Unity3d学习笔记(2)--一个太阳系的实现
- C# 利用Rar压缩文件并FTP上传
- .NET框架-微软C#编程风格官方指南
- SQL学习01
- C++学习记录10--冒泡排序
- svm学习笔记1
- cordova 插件调用activity和结果返回
- 上拉电阻与下拉电阻的作用和区别
- MyBatis学习二 MyBatis的配置文件详解
- Minimum Time Difference
- uboot主Makefile分析