So my question is why would we need IEnumerable when we have the dictionary object?
The question you've referred is about opposite: creating Dictionary
from IEnumerable
. So you have IEnumerable
and you'd like to have Dictionary
.
It can be required when you have e.g. e List
and you'd like to have quicker access to collection elements by one of the items property value.
And just to be sure, Dictionary<TKey, TValue>
already implements IEnumerable<T>
, so the conversion would not necessary in the opposite direction (unless you're trying to change the T
).