c# - How can I call the constructor? -


i dynamically create instances of objects in custom linq provider building using call:

 object result = activator.createinstance(typeof(t)); 

my t type implements abstract class has constructor take instance of object (t wrapper). question - there way can explicitly call non-default constructor can rid of this:

 myentity entity = result myentity;  if(entity != null)     entity.underlyingentity = e; //where e wrapping  

yes, supply constructor arguments after type object, so:

object result = activator.createinstance(typeof(t), arg1, arg2, ...); 

Comments

Popular posts from this blog

asp.net - repeatedly call AddImageUrl(url) to assemble pdf document -

java - Android recognize cell phone with keyboard or not? -

iphone - How would you achieve a LED Scrolling effect? -