我在这里调用了名为_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;
}