dynamic d = "hello";
Console.WriteLine (d.ToUpper()); // HELLO
Console.WriteLine (d.Foo()); // Compiles OK but gives runtime error
I'm reading a book an stumbled in this section, in the third line it only throws error during runtime but it will compile even though Foo
method doesn't exist.
Why not check it in compile time rather than in runtime?
Edit: What is the significance, and when can I use this concept?