Activator Class
Contains methods to create types of objects locally. This class cannot be inherited.
Namespace: System
Assembly: mscorlib (in mscorlib.dll)
The Activator type exposes the following members.
| Name | Description | |
|---|---|---|
![]() ![]() ![]() ![]() | CreateInstance(Type) | Creates an instance of the specified type by using that type's default constructor. |
![]() ![]() ![]() ![]() | CreateInstance(Type, array<Object>) | Creates an instance of the specified type by using the constructor that best matches the specified parameters. |
![]() ![]() ![]() ![]() | CreateInstance<T>() | Creates an instance of the type designated by the specified generic type parameter, using the parameterless constructor. |
![]() ![]() ![]() | Equals(Object) | Determines whether the specified Object is equal to the current Object. (Inherited from Object.) |
![]() ![]() ![]() | Finalize | Allows an object to try to free resources and perform other cleanup operations before the Object is reclaimed by garbage collection. (Inherited from Object.) |
![]() ![]() ![]() | GetHashCode | Serves as a hash function for a particular type. (Inherited from Object.) |
![]() ![]() ![]() | GetType | Gets the Type of the current instance. (Inherited from Object.) |
![]() ![]() ![]() | MemberwiseClone | Creates a shallow copy of the current Object. (Inherited from Object.) |
![]() ![]() ![]() | ToString | Returns a string that represents the current object. (Inherited from Object.) |
The CreateInstance method creates an instance of a type defined in an assembly by invoking the constructor that best matches the specified arguments. If no arguments are specified, the constructor that takes no parameters, that is, the default constructor, is invoked.
The type to be created and the constructor to be invoked must be accessible. For example, if you are using AssemblyBuilder to create a dynamic assembly, you can invoke an internal constructor (Friend constructor in Visual Basic) for a type defined within the dynamic assembly. However, if you are using DynamicMethod to create a dynamic method, you cannot invoke internal constructors, because the dynamic method is hosted in an anonymous module in a system-provided assembly.
A binder parameter specifies an object that searches an assembly for a suitable constructor. You can specify your own binder and search criteria. If no binder is specified, a default binder is used. For more information, see the System.Reflection::Binder and System.Reflection::BindingFlags classes.
If the instance is created locally, a reference to that object is returned. If the instance is created remotely, a reference to a proxy is returned. The remote object is manipulated through the proxy as if it were a local object.
For a list of the operating systems and browsers that are supported by Silverlight, see Supported Operating Systems and Browsers.

