c# 4.0 - How to create a List which contains a type of interface, to only add class types which inerhit this interface? -


i want create collection of class types, want types, not objects - inerhit

ibuildertype 

so how write list ->

public list<typeof(ibuildertype)> builder; 

to achieve :

var listbuilder = new list<typeof(ibuildertype)>          {typeof (basiccategorybuilder)}; 

i want basicly restriction types can add list (range of classes)

type isn't generic, cannot check @ compile time elements of list`1 types of ibuildertype. may want check type hierarchy code , encapsule list methods, there's no way constraint type in generics.

var listbuilder = new list<type/* : ibuildertype*/>() {     typeof(basiccategorybuilder) }; 

Comments

Popular posts from this blog

timeout - Handshake_timeout on RabbitMQ using python and pika from remote vm -

gcc - MinGW's ld cannot perform PE operations on non PE output file -

c# - Search and Add Comment with OpenXML for Word -