为什么可以调用受保护的或私有的CSharp方法/变量?

Kee*_*ker 5 .net c#

可能重复:
为什么私有字段对该类型是私有的,而不是实例?

考虑以下课程:

public class Test
{
    protected string name;
    private DateTime dateTime;

    public Test(string name)
    {
        this.name = name;
        this.dateTime = DateTime.Now;
    }

    public Test(Test otherObject)
    {
        this.name = otherObject.name;
        this.dateTime = otherObject.GetDateTime();
    }

    private DateTime GetDateTime()
    {
        return dateTime;
    }

    public override string ToString()
    {
        return name + ":" + dateTime.Ticks.ToString();
    }
}
Run Code Online (Sandbox Code Playgroud)

在我的构造函数中,我正在调用私有受保护的东西otherObject.为什么这可能?我一直认为私有是真的私有(暗示只有对象可以调用该方法/变量)或受保护(只能通过重载访问).

为什么以及何时需要使用这样的功能?

我缺少一些OO逻辑/原理吗?

ada*_*ost 5

来自MSDN(C#参考)

private关键字是成员访问修饰符.私有访问是最不宽容的访问级别.私有成员只能在类的主体或声明它们的结构体中访问.