我正在使用.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