Check out this program:
static class Program
{
static void Main()
{
GetLinks();
Console.WriteLine("Program failed!");
}
static IEnumerable<string> GetLinks()
{
throw new Exception();
foreach (var item in new string[] { })
yield return item;
}
}
It's very weird but the result of this program is Program failed!
, meaning the GetLinks
function is not even called.
What's the explanation of this behavior?