If the source collection of the foreach
statement is empty, the body of the foreach
statement isn’t executed and skipped.
If the foreach
statement is applied to null
, a NullReferenceException is thrown.
More Information:
https://learn.microsoft.com/en-us/dotnet/csharp/language-reference/statements/iteration-statements