Is there any way to optionally return a null with a \"return yield\" driven iterator?
I would like to return a null in some cases and I don\'t think this is particul
If you need to things like that (or throw things like ArgumentException immediately), you need to separate your iterator into two methods:
public IEnumerable GetItems() {
if (something) return null;
return GetItemsInternal();
}
private IEnumerable GetItemsInternal() {
// the actual iterator with "yield return" goes here.
}