Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我想从数据表列创建一组独特的项目。我知道如何创建数据视图...
DataView view = new DataView(table); DataTable distinctValues = view.ToTable(true, "Column1", "Column2" ...);
数组是否有类似的方法?提前致谢。
您可以使用 LINQ
DataTable myDataTable = new DataTable(); //...... string[] uniqueItems = myDataTable.AsEnumerable() .Select(r=> r.Field<string>("MyColumn")) .Distinct() .ToArray();
;