foreach (var name in parent.names)
{
if name.lastname == null)
{
Violated = true;
this.message = "lastname reqd";
}
if (!Violated)
{
Violated = !(name.firstname == null) ? false : true;
if (ruleViolated)
this.message = "firstname reqd";
}
}
每当违反为真时,我都想foreach
立即退出循环。我该怎么做?