我正在使用.NET Framework 3.5创建一个C#2010应用程序。使用C#的Linq库进行排序
我有一个包含几个列和行[显然]一个DataGridView。我将这个datagridview的行保存在表格List<string[]>
的结构中。我也有一个List<double>
其中包含系数。我想使用System.LINQ
库按系数排序结构。我曾尝试以下:
var linq_Query_rowrates = from rw in rows orderby matchrate descending select rw;
这突出的行查询,并显示以下错误:
Error 1 Could not find an implementation of the query pattern for source type '
System.Collections.Generic.List<string[]>
'. 'OrderByDescending
' not found. Are you missing a reference to 'System.Core.dll
' or a using directive for 'System.Linq
'?
是否有可能使用LINQ库,如果是进行排序这种结构, 怎么样?
注:我知道很多其他的方法来做到这一点的,我在使用LINQ库这样做只是感兴趣。
注:matchrate不是各行的成员,但使用行的成员也不起作用。
后来编辑:也许它应该是这样的?
var linq_Query_rowrates =
from rw in rows
join rate in matchrate
on matchrate equals rows
orderby matchrate descending
select rw;
你有没有引用“系统。Core.dll',并在源文件中包含'using System.Linq;'指令? – dtb
@dtb,是的,我一直在使用System.Linq的包括;并引用了dll。 –
行和系数如何相关?按索引? – clearpath