i'm having trouble figuring out proper syntax this.. have method so:
public idictionary<string, object> findtransactions() { dictionary<string, object> returnitems = new dictionary<string, object>(); //do stuff return returnitems; }
i want assign return value new variables consuming code. these aren't quite right:
idictionary returnitems = findtransactions(); //cannot implicitly convert type 'system.collections.generic.idictionary<string, object>' 'system.collections.idictionary'. explicit conversion exists (are missing cast?) dictionary<string, object> returnitems2 = findtransactions(); //cannot implicitly convert type 'system.collections.generic.idictionary<string, object>' 'system.collections.generic.dictionary<string, object>'. explicit conversion exists (are missing cast?)
...how done correctly?
you close in both cases:
idictionary<string, object> returnitems2 = findtransactions();
the generic idictionary<k,v>
interface not extend non-generic idictionary
can't cast that, , can't implicitly cast less-derived type (like interface) more derived type (like implementation), because there's no guarantee actual type dictionary<k, v>