c# - Referencing DLL Class with Strings -
is possible?
i have dll have been making, in class called modbusclient , named modbusrtu. in application add following code.
modbusclient client = new modbusclient(new modbusrtu());
it works, i'm trying add client dynamically 3 strings! following code.
string string1 = "modbus"; string string2 = "client"; string string3 = "rtu"; string1+string2 client = new string1+string2(new string1 + string3());
i know code snippet above never work but, believe best reflect idea.
you can use reflection..
string string1 = "modbus"; string string2 = "client"; string string3 = "rtu"; var modbusclienttype = type.gettype(string1+string2); var modbusrtutype = type.gettype(string1+ string3); var modbusrtuinstance = ativator.createinstance(modbusrtutype); var modbusclientinstance = activator.createinstance(modbusclienttype,modbusrtuinstance);
Comments
Post a Comment