(C# Coding Standard有多個版本
對於第
一
public class SomeClass
{
const int DefaultSize =
public void SomeMethod()
{}
}
void MyMethod(int someNumber)
{
int number;
}
interface IMyInterface
{}
public class SomeClass
{
private int m_Number;
}
object NOT Object
string NOT String
int NOT Int
// 正確
public class LinkedList<K
{}
// 避免
public class LinkedList<KeyType
{}
using System;
using System
using System
using System
using MyCompany;
using MyControls;
delegate void SomeDelegate();
public void SomeMethod()
{}
SomeDelegate someDelegate = SomeMethod;
public class MyClass
{
int m_Number;
string m_Name;
public void SomeMethod
{}
public void SomeMethod
{}
}
public partial class MyClass
{}
//In MyClass
public partial class MyClass
{}
//Correct:
void InvokeMethod()
{
SomeDelegate someDelegate = delegate(string name)
{
MessageBox
};
someDelegate(
}
//Avoid
void InvokeMethod()
{
SomeDelegate someDelegate = delegate(string name){MessageBox
someDelegate(
}
//正確
SomeDelegate someDelegate
{
MessageBox
};
//避免
SomeDelegate someDelegate
{
MessageBox
};
SomeDelegate someDelegate = (name)=>
{
Trace
MessageBox
};
void MyMethod(SomeDelegate someDelegate)
{}
//正確:
MyMethod(name=>MessageBox
//避免
MyMethod((name)=>{Trace
From:http://tw.wingwit.com/Article/program/net/201311/13227.html