Pop Quiz
public class MyBase
{
private string _foo = "Hello World";
public string Foo
{
get{ return _foo; }
}
}
public class Derived : MyBase
{
public void TestFooAccess()
{
//The below line won't obviously compile
//Console.WriteLine(_foo);
//What about this one, will it compile?
Console.WriteLine(Foo);
Console.ReadLine();
}
}
Yes it does compile and prints “Hello World” when called. Surprised?