Consider the following code :
class Program
{
    static void Main(string[] args)
    {
        var a = new A();
        var b = new B();
        Print(a);
        Print(b);
        Console.WriteLine(b.Hello);
        Console.ReadLine();
    }
    static void Print<T>(T t) where T : A
    {
        Console.WriteLine(typeof(T));
        Console.WriteLine(t.GetType());
        Console.WriteLine(t.Hello);
    }
}
public class A
{
    public string Hello { get { return "HelloA"; } }
}
public class B : A
{
    public new string Hello { get { return "HelloB"; } }
}
The output I got (.NET FW 4.5)
- //Print(a)
- A
- A
- HelloA
- //Print(b)
- B
- B
- HelloA
- //Explicit Writeline
- HelloB
Can anyone explain how I got the 2nd HelloA, as I was expecting HelloB ?
 
    