Recreating a Dictionary from an IEnumerable
- by learnerplates
But some of the callers is the Dictionary's TryGetValue and ContainsKey and so require the result of the method to be a Dictionary, how can I convert the IEnumerable into a Dictionary so that I can use TryGetValue ?
I've a method which at present returns an IEnumerable.
I want to make it more generic by making it return an IEnumerable.
method:
public IEnumerable<KeyValuePair<string, ArrayList>> GetComponents()
{
// ...
yield return new KeyValuePair<string, ArrayList>(t.Name, controlInformation);
}
caller:
Dictionary<string, ArrayList> actual = target.GetComponents();
actual.ContainsKey("something");