Why can't we use Reflection to equip an application with the ability to cast
an 'object' to it's "useful type" (e.g., MyDal) -- so that the application
that is calling Activator.Creat eInstance 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?
an 'object' to it's "useful type" (e.g., MyDal) -- so that the application
that is calling Activator.Creat eInstance 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
"1231231231 23") 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?