Just use FirstOrDefault (or SingleOrDefault, if unique).
var myItem = myArray.FirstOrDefault( x => x.Name == "Joe" );
Or if you want to force a BinarySearch and you know that the array is sorted
var myItem = Array.BinarySearch( myArray,
new MyClass { Name = "Joe" },
new MyClassNameComparer() );
where MyClassNameComparer is IComparer<MyClass>
and compares based on the name property.
If you don't want any temporary object -- I assume that a constant string is ok, otherwise you're lost -- then you can use.
var myItem = Array.BinarySearch( myArray,
"Joe",
MyClassOrStringComparer() );
Where MyClassOrStringComparer is able to compare a string to a MyClass object (and vice versa).
public class MyClassOrStringComparer
{
public int Compare( object a, object b )
{
if (object.Equals(a,b))
{
return 0;
}
else if (a == null)
{
return -1;
}
else if (b == null)
{
return 1;
}
string aName = null;
string bName = null;
if (a is string)
{
aName = a;
}
else
{
aName = ((MyClass)a).Name;
}
if (b is string)
{
bName = b;
}
else
{
bName = ((MyClass)b).Name;
}
return aName.CompareTo( b.Name );
}