Search code examples
atata

Index of a table row when found by predicate


I'm finding a TableRow with a predicate thus:

Table.Rows[r => r.name == "blablabla"]

Is there any way to get the index of the row it finds as an int?


Solution

  • IndexOf method should work for that:

    int index = Table.Rows.IndexOf(r => r.name == "blablabla");
    

    To assert index:

    Table.Rows.IndexOf(r => r.name == "blablabla").Should.Be(2);