Getting value (that may not exist) from within generic object
<p>I need a list which can have its items queried for a particular property, and then returns the item if that property has the correct value. I came up with the following:</p>

<pre><code>public class MyList&lt;T&gt;
{
    public T[] items;

    public Get( string name )
    {
        foreach( T item in items )
        {
            if( item.name == name )
                return item;
        }
        return null; // if not found
    }
}
</code></pre>

<p>The above gives a compile error because type T doesn't necessarily have the property that i'm checking. That makes sense, but what do I have to do to get this behaviour. Please note that I cannot use a Dictionary for reasons outside the scope of this question, although it is true that a Dictionary is essential what i'm trying to re-create.</p>
