mercredi 10 juillet 2019

Declaring a type in C# with a Type instance

How would one accomplish the following:

Type type = this.methodThatGivesDynamicType()
typeof(type) dynamicDTO = _mapper.Map(myObj, typeof(MyObj), type);

Or possibly use dynamic for dynamicDTO and cast it to type after the fact? The end result is I have an instance of Type, and I need to cast an object to that type. Specifically, I'm using AutoMapper with that Map method using a dynamically chosen Type.





Aucun commentaire:

Enregistrer un commentaire