I have this code:
public string foo { get; set; }
Now, I interpret this as my object has a public property called foo
, and both it's accessor's are public. If I write this:
private string foo { get; set; }
I interpret that as my object has a private property called foo
, and both it's accessor's are private. I understand making the property itself private. What I don't understand is why the accessor's must be more restrictive? If I write:
private string foo { public get; public set; }
I interpret that my object has a private property called foo
, and both's it's accessor's are public, which is the behavior that I want. I'd like the private property with public accessors. I mean, if I have to write a Get/Set method, I will. But I'm just confused as to why this is.