Using foreach loop on Dictionary<>
When I was trying to use foreach loop with classes or a value type I was doing it like that
foreach(int item in items)
{
//rest of the code
}
However when I tried to loop the Dictionary like that
foreach(Dictionary item in dictionaryobject)
{
//compile error
}
I got a compile error so I must use KeyValuePair
foreach(KeyValuePair item in dictionaryobject)
{
//code
}
Why must I use KeyValuePair instead of the Dictionary?