When you declare them as private, they can only be accessed from within that class, and no other:
public class MyBase
{
private string MyProp { get; set; }
public void Method(string s) { MyProp = s; }
public string OtherMethod() { return MyProp; }
}
public class MyDerived : MyBase
{
public void SetIt()
{
MyProp = "hello";
Method("Hello");
}
}
Even if you derive a new class from MyBase, the new class cannot access the private members. To allow that, you can declare it as protected:
{
protected string MyProp { get; set; }
public void Method(string s) { MyProp = s; }
public string OtherMethod() { return MyProp; }
}
public class MyDerived : MyBase
{
public void SetIt()
{
MyProp = "hello";
Method("Hello");
}
}
Anything declared within a class is available anywhere within that class regardless of the protection level, but you can restrict access to it outside the class, using the private, protected and internal specifiers.