I have a function that return a IDictionary<TKey, List<TValue> >
.
I have another function that takes a IDictionary<TKey, IEnumerable<TValue> >
.
I need to pass the return of the first function to the second function.
The compiler doesn't want to implicitlty convert the first into the second. So how could I convert the first into the second in O(1)?
I could always write a conversion function
public static IDictionary<TKey, IEnumerable<TValue>> ToIEnumerable<TKey, TValue>(this IDictionary<TKey, List<TValue>> source)
{
return source.ToDictionary(s => s.Key, s => s.Value.AsEnumerable());
}
But I'm pretty sure this is not O(1), more like O(log n).
A related question here : Nested Interfaces: Cast IDictionary< TKey, IList< TValue > > to IDictionary< TKey, IEnumerable < TValue> >?