© { JSL }
63
Text Box: typeof
typeof
Folded Corner:
·retrieving the exact type of an object
wSystem.Object.GetType() for variables
wtypeof for types known at compile time
wType.GetType() for types known at runtime
static void Main()
{
    Violin stradi = new Violin();
    IPluckable ip = stradi;
    Type t1 = ip.GetType();
    Type t2 = typeof(Violin);
    Type t3 = Type.GetType("Violin");
    Console.WriteLine(t1 == t2);
    Console.WriteLine(t2 == t3);
    Console.WriteLine((object)t1 == (object)t2);
    Console.WriteLine((object)t2 == (object)t3);
}
True
True
True
True