Using DataGridViewRowCollection object in LINQ

后端 未结 1 886
野的像风
野的像风 2020-12-10 01:18

I\'d like to use a DataGridViewRowCollection in a LINQ expression using extension methods and lambda expressions. Unfortunately, the extension methods are for t

1条回答
  •  春和景丽
    2020-12-10 01:37

    Yes, do this:

    var rows = yourDataGridViewRowCollection
                   .Cast()
                   .Where(row => row.index > 4);
    

    This uses the Enumerable.Cast extension method:

    The Cast(IEnumerable) method enables the standard query operators to be invoked on non-generic collections by supplying the necessary type information. For example, ArrayList does not implement IEnumerable, but by calling Cast(IEnumerable) on the ArrayList object, the standard query operators can then be used to query the sequence.

    0 讨论(0)
提交回复
热议问题