c# - How to cast to an object to a type when type is known during runtime? -


i have statement this: myclass myclass = report.datasource myclass

during runtime, type of datasource myclass it's in different namespace current running project. that's because 2 projects creating same classes same service reference. datasource points 1 namespace , myclass cast different namesapce. (it's complicated explain how occured)

during runtime, how use type returned report.datasource.gettype() (returns myclass namespace) , use type cast instead of 'myclass' in namespace don't want?

(i hope i've explained clearly. brain foggy now!)

unfortunately, it's not "same class in different namespace"... basically, have 2 classes. different classes, because of auto generated code.

as far .net runtime concerned, might different "int" , "string". hail different assemblies.

i've had similar issue - , @ point, easiest thing can make own generic converter method read public properties 1 type, , populate them on type.

this can done because promise 2 classes identical :)


Comments

Popular posts from this blog

ios - UICollectionView Self Sizing Cells with Auto Layout -

node.js - ldapjs - write after end error -

DOM Manipulation in Wordpress (and elsewhere) using php -