c# - define collection of a type that was retrieved by a method (no reflection) -


i have interface idomain 1 method gives me element type of domain:

interface idomain {     type elementtype { get; } } 

i want create collection of appropriate element type given idomain. how do that?

the following not work:

idomain dom = ... // somewhere type elemtype = dom.elementtype; icollection<elemtype> mycoll = new hashset<elemtype>(); // error: "'elemtype' variable used type" 

writing icollection<typeof(elemtype)> not either.

it should noted dom.elementtype can of type a, b or c. know @ point of code, because wrote way.

is there other way achieve without using reflection?


Comments

Popular posts from this blog

angular - Ionic slides - dynamically add slides before and after -

minify - Minimizing css files -

Add a dynamic header in angular 2 http provider -