using System.Collections.Generic;
public bool CheckboxField {get;set;}
this.CheckboxField = (i % 3 == 0);
public static IEnumerable<TableRow> GenerateTableRows(int howMany)
for (int i=0; i<howMany; i++)
yield return new TableRow(i);
public static void Main()
Console.WriteLine("Done");
ICollection<TableRow> myTable = new List<TableRow>(TableRow.GenerateTableRows(12));
while (myTable.Count(x => !x.CheckboxField) > 0)
var randomRecord = GetRandomRecord(myTable);
Console.WriteLine(randomRecord == null ? "No Matching Rows Exist" : randomRecord.I.ToString());
TableRow GetRandomRecord(ICollection<TableRow> myTable)
var randomRecord = myTable
.Where(x => !x.CheckboxField)
.OrderBy(x => rnd.Next())
randomRecord.CheckboxField = true;