Why can't we use Reflection to equip an application with the ability to castThe difference between compile & runtime. CreateInstance works at
an 'object' to it's "useful type" (e.g., MyDal) -- so that the application
that is calling Activator.CreateInstance can itself, at compile time, _not_
know anything about the MyDal type (a class), and instead acquire that
knowledge at runtime. Ideally, the application could somehow cast 'object'
types to "real types" without having any compile-time knowledge of the "real
type."
What am I missing?
runtime, you can pass ANY string to it (even an incorrect one like
"123123123123") and it will compile
Only at runtime you will get the error.
And honestly, you HAVE to know something about your Class. otherwise,
how do you know which method to call?