mardi 1 septembre 2015

Using a type obtained through reflection in a data structure?

I have a class FutureClass that exists in .NET 4.6, but I'd like to be able to use it in an older codebase that builds with .NET 4.0. I can obtain and call FutureClass objects, but I want to store them in, say, a Dictionary<string, FutureClass>.

I've tried the following:

Dictionary<string, FutureClass> dict = new Dictionary<string, FutureClass>(); // didn't expect it to work

and

Type futureClassType = [...] //dynamically load the type from the assembly compiled with .NET 4.6
Dictionary<string, futureClassType> dict = new Dictionary<string, futureClassType>(); // held some promise, I thought

Is there a way to do what I'm trying? Thanks!





Aucun commentaire:

Enregistrer un commentaire