Exemple #1
0
 /// <summary>
 /// Creates an instance of the specified type using the constructor that best matches the specified parameters.
 /// </summary>
 /// <param name="type">The type of object to create.</param>
 /// <param name="args">
 /// An array of arguments that match in number, order, and type the parameters of the constructor to invoke.
 /// If args is an empty array or null, the constructor that takes no parameters (the default constructor) is invoked.</param>
 /// <returns>A reference to the newly created object.</returns>
 public static object CreateInstance(Type type, params object[] args)
 {
     if (type == null)
     {
         throw new ArgumentNullException("type");
     }
     return(RuntimeHelpers.CreateInstance(type, args));
 }