Why are my privates accessible?

后端 未结 5 803
温柔的废话
温柔的废话 2021-01-19 05:47

I have the following code:

public class PersonInitializer
{
    private Person _person;

    public static Person LoadFromFile(string path)
    {
        Per         


        
5条回答
  •  小蘑菇
    小蘑菇 (楼主)
    2021-01-19 06:28

    Private variable's/references are accessible only in the class in which they are defined.
    Since in you case, the reference Person _person; is defined in the same class from where you are accessing it, it is accessible.

提交回复
热议问题