문제

Does an ienumerable obtained from a yield expression can ever be null?

도움이 되었습니까?

해결책

No. The C# compiler converts your iterator block into an iterator instance, which is what is returned from your method. This can never be null.

That said, it is of course possible to yield null values within your enumeration, provided that the generic type of your enumerable is a reference type or a nullable type.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top