C#之命名规范
2024-05-31 本文已影响0人
小羊爱学习
PascalCase:类名、枚举名、属性、常量、事件和公共方法名。
camelCase:方法参数、局部变量和私有字段(私有变量)。
注意:
-
私有方法不遵循大驼峰,可以使用大驼峰或者小驼峰都可以,还是建议使用大驼峰。
-
接口定义使用Pascal规则,且必须以大写“I”开头。
-
事件处理器方法名通常以On开头。
public interface IStudentRepository
{
Student GetStudentByName(string name);
}
public class StudentService
{
private void OnStudentUpdated(EventArgs e)
{
// 事件处理器实现
}
}