Any ideas to simplify this beauty; I would prefer a LinQ expression if possible:
private object[] array;
public abstract bool Condition(object o);
//...
private object FindStuff()
{
for (int i = 0; i < array.Length; i++)
{
if (Condition(array[i]))
{
return i == 0 ? null : array[i-1];
}
}
throw new ItemNotFoundException();
}
//...
object foo;
as a non-valid data-placeholder, I have a new approach but I hate it even more:return array.Select((t, i) => Condition(t) ? i == 0 ? null : array[i - 1] : foo).First(e => e != foo);
– Markus 2 days ago