Selasa, 15 Juni 2010

Hide and seek

Another interesting question from StackOverflow. That thing is a gold mine for blog topics. Consider the following:class B{  public int X() { return 123; }}class D : B{  new protected int X() { return 456; } }class E : D{  public int Y() { return X(); } // returns 456}class P{  public static void Main()  {    D d = new D();    Console.WriteLine(d.X());  }}There are two possible behaviours here.

Tidak ada komentar:

Posting Komentar