简体   繁体   English

从屈服中产生的数量是否可以为空?

[英]Does ienumerable from yielding can ever be null?

从yield表达式获得的可相关数是否可以为空?

No. The C# compiler converts your iterator block into an iterator instance, which is what is returned from your method. 否.C#编译器将迭代器块转换为迭代器实例,该实例是从方法返回的。 This can never be null . 这永远不会为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. 也就是说,只要枚举的泛型类型是引用类型或可空类型,当然可以在枚举中产生null值。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM