Array.BinarySearch where a certain condition is met
Posted
by codymanix
on Stack Overflow
See other posts from Stack Overflow
or by codymanix
Published on 2010-03-21T22:10:58Z
Indexed on
2010/03/21
22:11 UTC
Read the original article
Hit count: 344
I have an array of a certain type. Now I want to find an entry where a certain condition is met.
What is the preferred way to do this with the restriction that I don't want to create a temporary object to find, but instead I only want to give a search condition.
MyClass[] myArray;
// fill and sort array..
MyClass item = Array.BinarySearch(myArray, x=>x.Name=="Joe"); // is this possible?
Maybe is it possible to use LINQ to solve it?
© Stack Overflow or respective owner