foreach(Value v in myDictionary[key])
In this scenario, is the compiler able to determine that myDictionary[key] will always be the same and not hash the [key] every iteration of foreach?
foreach(Value v in myEnumerable.Where(s => s.IsTrue))
I know enumerables are lazy, I suspect that in this case, the .Where only resolves once and returns a full collection for the foreach but that is only a hunch.
Judging by this question, the foreach is doing a .GetEnumerable even in scenario 1, so its the return of that which is used so therefore it only resolves once and not on every iteration.