The System.Activator Class
The System.Activator class is the key to the .NET late binding process. Beyond the methods inher-
ited from System.Object, Activator defines only a small set of members, many of which have to do
with the .NET remoting API. For our current example, we are only interested in the Activator.
CreateInstance() method, which is used to create an instance of a type à la late binding.
This method has been overloaded numerous times to provide a good deal of flexibility. The
simplest variation of the CreateInstance() member takes a valid Type object that describes the
entity you wish to allocate on the fly. Create a new Console Application named LateBindingApp,
and update the Main() method as follows (be sure to place a copy of CarLibrary.dll in the project’s
\bin\Debug directory):
Do'stlaringiz bilan baham: |