what is the difference between these two snippets of code. I want to know why he use all that amount of code at the second snippet while he could just use simple new to create an instance of DataTable;
1) var dt = new DataTable();
2) var dt = ObjectBuilder.Instance<DataTable>();
.
public class ObjectBuilder
{
#region ObjectBuilder Members
/// <summary>
/// Instances this instance.
/// </summary>
/// <typeparam name="T"></typeparam>
/// <returns></returns>
public static T Instance<T>() where T : class
{
return Activator.CreateInstance<T>();
}
/// <summary>
/// Instances the specified arguments.
/// </summary>
/// <typeparam name="T"></typeparam>
/// <param name="arguments">The arguments.</param>
/// <returns></returns>
public static T Instance<T>(params object[] arguments) where T : class
{
return (T)Activator.CreateInstance(typeof(T), arguments);
}
}
Aucun commentaire:
Enregistrer un commentaire