If so, on what .NET Framework versions is it supported?
I have tested this on .NET Framework 4.0 and it works fine:
using System;
using System.Collections.Generic;
public class TestClass
{
public IEnumerable Defer()
{
yield return 1;
yield return 2;
yield return 3;
}
}
Yes, it is supported ever since the yield keyword was. The only difference is that it's more or less IEnumerable<object>, which might lead to inefficiencies if it has to do boxing. Other than that, it's exactly the same.
As the yield keywords are reduced to compiler trickery, presumably this should work. It certainly works for the 2.0 runtime; I'd hesitate to make any statements about 1.1, however.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With