I have a class like so:
public class MyClass
{
public char letter { get; set; }
public double result { get; set; }
public bool test { get; set; }
}
I declare an array:
MyClass[] myArray = new MyClass[counter];
and fill it with some data.
I sort the array:
myArray = myArray.OrderBy(a => a.letter).ThenByDescending(a => a.result).ToArray();
Now let's say I have an int i = 100 variable.
How would I iterate through this array fields and get the index of the first element that:
- Has specified letter in letter field.
- Has
test == false result < i
I'm thinking of something like this:
foreach(MyClass t in myArray.Where(a => a.letter == 'a')
{
if(t.result < i && t.test == false) get index of that field
}
However, I'm unsure how to get the index of it. How do I do this?
stringor contain expression should be equalsforinstead of aforeachand do the filtering inside theforwith anif.