oop - Convert IList<Interface> to List<Class> -


list<currentelectionservice> result = new list<currentelectionservice>();     result = oelectionsmanager.getcurrentelectionsbyeid(     employeeid.stringtoguid(), planyear) list<currentelectionservice>;  public class currentelectionservice : icurentelection {    // implement interface fields here } 

the method getcurrentelectionsbyeid returns me ilist<icurentelection> , want cast interface class currentelectionservice, returns null. please help.

why not use linq perform cast

list<currentelectionservice> result = oelectionsmanager.getcurrentelectionsbyeid(     employeeid.stringtoguid(), planyear).cast<currentelectionservice>().tolist(); 

i hope helps.


Comments

Popular posts from this blog

javascript - Count length of each class -

What design pattern is this code in Javascript? -

hadoop - Restrict secondarynamenode to be installed and run on any other node in the cluster -