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

c# - SelectList with Dictionary, add values to the Dictionary after it's assigned to SelectList -

how can i manage url using .htaccess in php? -

ios - I get the error Property '...' not found on object of type '...' -