Yes - and no.
You can access it in the derived class:
public class Base
{
protected string myString;
}
public class Derived : Base
{
public Derived()
{
myString = "Hello World";
}
}
but you can't access it from outside either via the instance object:
private void MyMethod()
{
Derived d = new Derived();
d.myString = "goodbye";
}
Unless you encapsulate it in a property and specify the setter and getter:
private void MyMethod()
{
Derived d = new Derived();
d.MyString = "goodbye";
}
...
public class Base
{
protected string myString;
}
public class Derived : Base
{
public string MyString { get { return myString; } set { myString = value; } }
public Derived()
{
myString = "Hello World";
}
}