In this implementation does hand will be evaluated each time and return another list ?
foreach (Card card in hand.Cards)
{
}
Should we replace the above implementation with the following?
var cards = hand.Cards;
foreach (Card card in cards)
{
}
No. Actually the two snippets result in the same code.
In the snippet below:
hand.Cardsis going to be called only once.Edit:
I’ve created a small snippet, that I hope will show that there is no difference at all:
The otuput (for both methods) is as follows: