How to Pass Parameters to Activator.CreateInstance()

前端 未结 5 549
名媛妹妹
名媛妹妹 2020-11-28 04:42

I want to create an instance of a type that I specify in a generic method that I have. This type has a number of overloaded constructors. I\'d like to be able to pass argume

5条回答
  •  醉话见心
    2020-11-28 05:14

    As an alternative to Activator.CreateInstance, FastObjectFactory in the linked url preforms better than Activator (as of .NET 4.0 and significantly better than .NET 3.5. No tests/stats done with .NET 4.5). See StackOverflow post for stats, info and code:

    How to pass ctor args in Activator.CreateInstance or use IL?

提交回复
热议问题