You're not accessing it from inside the class, you're trying to access the variable as though it were public
. You would not expect this to compile, and this is pretty much what you are trying to do:
public class SomethingElse
{
public void CallHowdy()
{
A a = new A();
Console.WriteLine(a.Howdy);
}
}
There is no relationship, and it sounds like you are confused why that field is not public.
Now, you could do this, if you wanted to:
public class B : A
{
public void CallHowdy()
{
Console.Writeline(Howdy);
}
}
Because B
has inherited the data from A
in this instance.