a) Can Object.GetType
also be used for late binding ( Book I’m reading says it can’t be used for late-binding )?
For example, assuming we use late binding ( by dynamically loading an assembly A
, calling A.GetType(“T”)
and then calling Activator.CreateInstance
) to create an instance (I
) of type (T
) not known at compile time and if we then pass I
as an argument to method M, would o.GetType
be able to extract metadata from T
and create Type
object using this extracted metadata?
void M ( object o )
{
Type someType = o.GetType() ;
}
b) If yes --> how is o.GetType
able to extract the metadata about o
, since program’s assembly doesn’t contain any metadata on type T
( here I’m assuming that Object.GetType
consults assembly’s metadata when trying to gt information about particular type )?
thanx