C# how to find a value in a List collection
<p>I have a list this list contains a collection of the following class</p>

<pre><code>public class MyFile
{
    public string FileName
    {
        get;
        set;
    }

    public int Position
    {
        get;
        set;
    }
}
</code></pre>

<p>So ofc the list definition will look like this:</p>

<pre><code>private List&lt;MyFile&gt; MyFiles = new List&lt;MyFile&gt;();
</code></pre>

<p>I can also search the collection using:</p>

<pre><code>MyFile tmpFile = MyFiles.Find(delegate(MyFile item) 
   { return item.FileName == fileName; });
</code></pre>

<p>So far looking good, except what I would like to do is return the MyFile that not only matches the file name but that also has the highest value in field pos. </p>

<p>So if the following items exist in the list:</p>

<pre><code>myDocument.doc|1
myDocument.doc|2
myDocument.doc|3
myPDF.pdf|1
myPDF.pdf|2
myPDF.pdf|3
</code></pre>

<p>and the value of fileName = "myDocument.doc" in my find method, then I am still missing logic to return myDocument.doc|3 this item, because this has the highest value of pos. </p>

<p>In SQL my query would be</p>

<pre><code>select top 1 * from MyFiles 
where fileName = 'myDocument.doc' 
order by position desc;
</code></pre>

<p>Thanks in advance. </p>
