Matching Id with that of an object in an array
<p>what is a better way of implementing this pattern?:</p>

<pre><code>void ValidateId(int Id, MyObject[] objects)
{
    foreach (var myObject in objects)
    {
        if (Id == myObject.Id){
            return;
        }
    }
    throw new Exception("Invalid Id");
}
</code></pre>
