Sijin Joseph's blog

My experiences with .Net

March 2004 - Posts

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?

Posted: Mar 25 2004, 07:13 PM by Sijin Joseph | with 8 comment(s)
Filed under:
How to Argue about Typing

Bruce Eckel has an excellent discussion on typing in programming languages. 

3-22-04 How to Argue about Typing
[
Thinking About Computing]

More Posts