Please also consider the simplest option, using
System.Collections.Generic.List<T>.Find
:
http://msdn.microsoft.com/en-us/library/6sh2ey19.aspx[
^].
In addition to a correct answer by Oleksandr Kulchytsky, please see my comments to this answer.
The thing about overriding of
System.Object.Equals
and
System.Object.GetHashCode
is not so trivial. I saw even pretty experienced developers who were confused. Short explanation is: it's important for some collection classes providing access by a key. For more detailed explanation, please see my past answer, recently updated:
Object.GetHashCode() Method in C#.Net[
^].
This is interesting enough and very important to understand, please see.
Good luck,
—SA