Recently I had to task to create a dynamic object creation factory in C#. So I thought I test all the options I have to check what performs best.
I also wanted to check the performance implications these options have with the number of parameters in the constructor.
- new T() – Using the new/constructor method to
- Activator.CreateInstance(typeof(T)) – Using the Activator class to instantiate objects
- ConstructorInfo.Invoke() – Using the constructor info reflection class to instantiate objects
- Func<T>() – Using compiled lambda expressions to instantiate objects
I ran some tests to see calculate how each …