惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

Forbes - Security
Forbes - Security
GbyAI
GbyAI
OSCHINA 社区最新新闻
OSCHINA 社区最新新闻
S
SegmentFault 最新的问题
Y
Y Combinator Blog
Recorded Future
Recorded Future
博客园 - Franky
I
InfoQ
T
The Blog of Author Tim Ferriss
Recent Announcements
Recent Announcements
Cyber Security Advisories - MS-ISAC
Cyber Security Advisories - MS-ISAC
博客园_首页
阮一峰的网络日志
阮一峰的网络日志
T
Tailwind CSS Blog
Cyberwarzone
Cyberwarzone
The Register - Security
The Register - Security
H
Hackread – Cybersecurity News, Data Breaches, AI and More
Threat Intelligence Blog | Flashpoint
Threat Intelligence Blog | Flashpoint
雷峰网
雷峰网
P
Palo Alto Networks Blog
G
GRAHAM CLULEY
Cloudbric
Cloudbric
CTFtime.org: upcoming CTF events
CTFtime.org: upcoming CTF events
MongoDB | Blog
MongoDB | Blog
F
Full Disclosure
Google DeepMind News
Google DeepMind News
Recent Commits to openclaw:main
Recent Commits to openclaw:main
C
Check Point Blog
爱范儿
爱范儿
The GitHub Blog
The GitHub Blog
cs.AI updates on arXiv.org
cs.AI updates on arXiv.org
W
WeLiveSecurity
T
Threat Research - Cisco Blogs
U
Unit 42
N
Netflix TechBlog - Medium
The Cloudflare Blog
Spread Privacy
Spread Privacy
Microsoft Azure Blog
Microsoft Azure Blog
美团技术团队
T
Troy Hunt's Blog
Engineering at Meta
Engineering at Meta
H
Heimdal Security Blog
TaoSecurity Blog
TaoSecurity Blog
C
Cybersecurity and Infrastructure Security Agency CISA
T
Tenable Blog
B
Blog
S
Securelist
H
Hacker News: Front Page
Google Online Security Blog
Google Online Security Blog
G
Google Developers Blog

博客园 - 风语者

一些杂项资料 今天遇到的一个奇怪的vb.net问题 asp.net页面请求实现过程 中国人的成功十要 《.net组件开发第2版》下载 IE7.0(beta)可以下载了 Google Talk中的小秘密 - 风语者 - 博客园 今天的microsoft,明天的google C# 代码标准 .NET2.0版(七)Security 编码指导方针 C# 代码标准 .NET2.0版(六)Remoting 编码指导方针 C# 代码标准 .NET2.0版(五)序列化Serialization 编码指导方针 C# 代码标准 .NET2.0版(四)多线程编码指导方针 C# 代码标准 .NET2.0版(三)项目设置和结构 C# 代码标准 .NET2.0版(二)编码惯例和约定 一些很少用到但还不错的Html功能 - 风语者 - 博客园 常见程序进程(转载) Google提供的好工具 关于Response.ContentType 合并数据记录的问题
C# 代码标准 .NET2.0版(一)命名和风格
风语者 · 2005-08-22 · via 博客园 - 风语者

1.Use Pascal casing for type and method names and constants:

public class SomeClass
{
   const int DefaultSize = 100;
   public SomeMethod( )
   {}
}

2.Use camel casing for local variable names and method arguments:

int number;
void MyMethod(int someNumber)
{}

3.Prefix interface names with I:

interface IMyInterface
{..}

4.Prefix private member variables with m_.

5.Suffix custom attribute classes with Attribute.

6.Suffix custom exception classes with Exception.

7.Name methods using verb/object pairs, such as ShowDialog( ).

8.Methods with return values should have names describing the values returned, such as GetObjectState( ).

9.Use descriptive variable names.

10.Avoid single-character variable names, such as i or t. Use index or temp instead.

11.Avoid using Hungarian notation for public or protected members.

12.Avoid abbreviating words (such as num instead of number).

13.Always use C# predefined types, rather than the aliases in the System namespace. For example:

object NOT Object
string NOT String
intNOT Int32

14.With generics, use capital letters for types. Reserve suffixing Type for when dealing with the .NET type Type:

//Correct:
public class LinkedList<K,T>
{...}
//Avoid:
public class LinkedList<KeyType,DataType>
{...}

15.Use meaningful namespace names, such as the product name or the company name.

Avoid fully qualified type names. Use the using statement instead.

Avoid putting a using statement inside a namespace.

Group all framework namespaces together and put custom or third-party namespaces underneath:

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using MyCompany;
using MyControls;

16.Use delegate inference instead of explicit delegate instantiation:

delegate void SomeDelegate( );
public void SomeMethod( )
{...}
SomeDelegate someDelegate = SomeMethod;

17.Maintain strict indentation. Do not use tabs or nonstandard indentation, such as one space. Recommended values are three or four spaces.

18.Indent comments at the same level of indentation as the code that you are documenting.

19.All comments should pass spellchecking. Misspelled comments indicate sloppy development.

20.All member variables should be declared at the top, with one line separating them from the properties or methods:

public class MyClass
{
   int m_Number;
   string m_Name;

   public void SomeMethod1( )
   {}
   public void SomeMethod2( )
   {}
}

21.Declare a local variable as close as possible to its first use.

22.A filename should reflect the class it contains.

23.When using partial types and allocating a part per file, name each file after the logical part that part plays. For example:

//In MyClass.cs
public partial class MyClass
{...}
//In MyClass.Designer.cs
public partial class MyClass
{...}

24.Always place an open curly brace ({) in a new line.

25.With anonymous methods, mimic the code layout of a regular method, aligned with the anonymous delegate declaration (this complies with placing an open curly brace in a new line):

delegate void SomeDelegate(string someString);
//Correct:
public void InvokeMethod( )
{
   SomeDelegate someDelegate = delegate(string name)
                               {
                                  MessageBox.Show(name);
                               };
   someDelegate("Juval");
}
//Avoid
public void InvokeMethod( )
{
   SomeDelegate someDelegate = delegate(string name){MessageBox.Show(name);};
   someDelegate("Juval");
}

26.Use empty parentheses on parameter-less anonymous methods. Omit the parentheses only if the anonymous method could have been used on any delegate:

delegate void SomeDelegate( );
//Correct
SomeDelegate someDelegate1 = delegate( )
                             {
                               MessageBox.Show("Hello");
                             };
//Avoid
SomeDelegate someDelegate1 = delegate
                             {
                                MessageBox.Show("Hello");
                             };