public class DataGrid
{
public void DataBind() { }
}
常數、控制項 ID 可用 Pascal 或 camel。
public class Product
{
private string _productId;
private string _productName;
public void AddProduct(string productId, string productName) { }
}
public class BaseView : ViewPage
{
protected Label label; // camelCase 控制項 ID
protected Login Login1; // PascalCase 命名空間/型別 ID
}
public class DataBase
{
private string _connectionString;
}
public interface IConvertible
{
byte ToByte();
}
public class TableAttribute : Attribute { }
// 使用時可省略 Attribute 後綴:[Table]
public class NullEmptyException : Exception { }
public class File
{
public void CreateFile(string filePath) { }
public void GetPath(string path) { }
public void Delete(string fileName) { } // 參數 fileName 為賓語,方法名只保留動詞
}
這 7 條為基礎核心規範,後續篇章將延伸更多實務細節。