【发布时间】:2009-07-30 20:13:04
【问题描述】:
根据我的阅读,
yield return <value>
在执行该行的那一刻跳出函数。然而,Scott Guthrie 的文字表明
var errors = dinner.GetRuleViolations();
即使 GetRuleViolations 是一个很长的列表,也成功地提取出所有违反规则的列表
if(String.someFunction(text))
yield return new RuleViolation("Scary message");
if(String.anotherFunction(text))
yield return new RuleViolation("Another scary message");
这是如何工作的?
【问题讨论】:
标签: c# asp.net-mvc nerddinner yield-return