c# - Cannot implicitly conver type System.Collection.Generic.Dictionary<string,IList<string>> to System.Collection.Generic.Dictionary<string,IList<string>> -
i have getting error when try insert value using method item.todictionary()
b
dictionary<string,ilist<string>>
a
initialized it.
cannot implicitly conver type system.collection.generic.dictionary<string,list<string>> system.collection.generic.dictionary<string,ilist<string>>
var b = item.todictionary();
i used function create b , try insert a.
public class example { private dictionary<string, ilist<string>> a; private string c; private ilist<string> d; public example() { d = new list<string>(); = new dictionary<string, ilist<string>>(); } public void getdictionary() { var b = c.todictionary(e=>c, f=>d.tolist()); = b; } }
the problem d.tolist() returns list<string>
, b of type dictionary<string, list<string>>
, different dictionary<string, ilist<string>>
. can cast ilist<string>
solve problem:
public void getdictionary() { var b = c.todictionary(e => c, f => (ilist<string>) d.tolist()); = b; }
Comments
Post a Comment