对于我在这里称为"_Add“的私有方法,是否有命名约定?我不喜欢前面的下划线,但这是我的一个队友建议的。
public Vector Add(Vector vector) {
// check vector for null, and compare Length to vector.Length
return _Add(vector);
}
public static Vector Add(Vector vector1, Vector vector2) {
// check parameters for null, and compare Lengths
Vector returnVector = vector1.Clone()
return returnVector._Add(vector2);
}
private Vector _Add(Vector vector) {
for (int index = 0; index < Length; index++) {
this[index] += vector[index];
}
return this;
}发布于 2008-12-20 23:11:01
就我个人而言,对于方法,无论可见性如何,我都有相同的命名约定。
以下是我对C#的命名约定:
属性命名空间,类型,方法,属性: PascalCase
编辑:请注意,我为私有方法使用前缀名称而感到内疚。当我第一次读到你的问题时,我没有听懂。
例如,如果我有7种不同的方式通过我的DatabaseCommand类执行我的SQL语句,像QueryDataTable,QueryEnumerable,QueryEnumerable<T>,QueryDataReader等等,那么所有这些都想调用相同的私有方法,我倾向于将这个方法称为InternalQuery或PrivateQuery。
https://stackoverflow.com/questions/383850
复制相似问题