从我读过,NerdDinner示例的Dinner.GetRuleViolations函数如何返回一个列表?
yield return <value>
跳出函数的执行行的时刻。然而,斯科特·格思里的文字表示
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");
列表如何工作的呢?