当你将成员设为私有时,它对其他类(而不是类本身)是私有的。
例如,如果你有一个Equals方法需要访问另一个实例的私有成员,则此方法很有用:
public class AClass{ private int privateMemberA; // This version of Equals has been simplified // for the purpose of exemplifying my point, it shouldn't be copied as is public override bool Equals(object obj) { var otherInstance = obj as AClass; if (otherInstance == null) { return null; } return otherInstance.privateMemberA == this.privateMemberA; }}


