using System.Reflection;
internal class TestReflection
{
public static IEnumerable<object> ParseType(Type t)
{
foreach (MemberInfo mi in t.GetMembers())
{
yield return mi;
foreach (object x in mi.GetCustomAttributes(true))
{
yield return x;
}
}
}
}
So my question is how does the iterator know when to step into the nested foreach. I had assumed that the first yield return would always execute and the nested yield return is never executed. But this is not the case, which indicates there's something I don't quite understand about the yield return statement.
Can someone explain this?
Thanks James