c# - Create Instance using base constructor -


for reasons out of scope of question, i'm needing dynamically create instance of child class inherits base class, calling constructor doesn't exist argument passed base class constructor

using example below: should create instance of exampleclass sending value argument1 of baseclass.

class baseclass {     public baseclass()     {      }     public baseclass(string argument1)     {         //...     } }  class exampleclass : baseclass {     public exampleclass()     {     } } 

edit: made topic explain source or problem: entity framework dbcontext dynamic instatiation custom connection string

if understand correct can't modify exampleclass need create instance of uses different constructor base class?

i belive there not build in way in framework achive it, reflection. goal should bypass framework , use msil

however, topic found on looks promissing.

dynamically create type , call constructor of base-class


Comments

Popular posts from this blog

linux - Does gcc have any options to add version info in ELF binary file? -

android - send complex objects as post php java -

charts - What graph/dashboard product is facebook using in Dashboard: PUE & WUE -