代码改变世界

Creating instance of type without default constructor in c#

2012-08-22 18:25  hongjiumu  阅读(229)  评论(0编辑  收藏  举报

Use this override of the CreateInstance method:

public static object CreateInstance(

  Type type,

  params object[] args

)

creates an instance of the specified type using the constructor that best matches the specified parameters.

See: http://msdn.microsoft.com/en-us/library/wcxyzt4d.aspx

很喜欢这样的做法!值得记牢!