I don't really need this feature, but an opportunity to simplify some code has presented itself if I could get the compiler to permit yield return with another IEnumerable<>. Example shown below:
static void Main(string[] args){
foreach (string str in EnumerateA())
Console.WriteLine(str);
}
static IEnumerable<string> EnumerateA(){
yield return "1";
yield return EnumerateB("2");
yield return EnumerateB("3");
}
static IEnumerable<string> EnumerateB(string num){
yield return num + "+";
yield return num + "-";
}
I know that I can replace
yield return EnumerateB("2")
with
foreach(string str in EnumerateB("2")) yield return str;
and have that work, but is that the only way this would work? I'm targeting .NET 2.0.