Exiting Foreach loop in C#
<pre><code>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";
                }
            }
</code></pre>

<p>// whenever violated is true I want to get out of the foreach loop immediately. How do I do it? </p>
