C# Distinct去重DataTable
2021-03-13 03:28
标签:code tin new opp stage 表达式 pop ima ack C# Distinct去重DataTable 标签:code tin new opp stage 表达式 pop ima ack 原文地址:https://www.cnblogs.com/LuckyZLi/p/12558802.html
DataView
去重1. Source Data
DataTable dtSource = new DataTable();
dtSource.Columns.Add("UserID", System.Type.GetType("System.String"));
dtSource.Columns.Add("UserName", System.Type.GetType("System.String"));
dtSource.Columns.Add("Stage", System.Type.GetType("System.String"));
DataRow dr = dtSource.NewRow();
for (int i = 0; i
2. 使用
DataView
去重DataView dv = dtSource.DefaultView;
dv.Sort = "UserID ASC";
DataTable distinctDT = dv.ToTable("NewData", true, new string[] { "UserID", "UserName", "Stage" });
3. 使用Lambda表达式去重
DataTable distinctDT = dtSource.Clone();
var distinctRows = dtSource.AsEnumerable().Cast
上一篇:windows下Scala安装
下一篇:WPF入门教程(一)---基础
文章标题:C# Distinct去重DataTable
文章链接:http://soscw.com/index.php/essay/63947.html