excel导入到内存表后,如何对内存表做出汇总 groupby 目前excel表结构是 A 10B 5C 6A 5B 5C 14到内存表应该是 A 15B 10C 20请问如何操作 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 IList<Test> tlist = new List<Test>(); tlist.Add(new Test() {Key="A",Value=15 }); tlist.Add(new Test() { Key = "B", Value = 10 }); tlist.Add(new Test() { Key = "A", Value = 5 }); tlist.Add(new Test() { Key = "B", Value = 6 }); var rst = (from t in tlist group t by t.Key into tt select new {k= tt.Key, r=tt.Sum(x => x.Value) }).ToList();这种效果? 这是linq? 应该是这种效果吧 但我不想用linq 想直接用datatable操作 List<string> list = new List<string>(); for (int i = 0; i < 10; i++) { for (int j = 0; j < 10; j++) { if (!list.Contains(i.ToString())) { dt.Rows.Add(); list.Add(i.ToString()); dt.Rows[0][1] = j; } else { continue; } }兩個表循環一下啊,A,b,c用list保存 https://www.cnblogs.com/sydeveloper/archive/2013/03/29/2988669.htmllinq to dataTable了解一下 asenumerable() 一下即可https://blog.csdn.net/zx13525079024/article/details/7277425 迷茫ING,恳求指点:怎么样能快速学习C#,网站方面的???谢谢了。。。 关于listbox显示数据问题 把一组jpg图片转换成视频流 如何用c#远程连接sql server2005,连接字符串怎么写? 关于DataGrid的记录选择问题 如何在程序中发邮件? c#winform程序怎么判断浏览器是否打开,如果打开则强制关闭 水晶报表分页连续打印。 我找到了C#的最新编译器~~~~~~~~~~ 写一个BAT文件,运行不了 求大神 VRTK有一个报错,菜鸟求救
tlist.Add(new Test() {Key="A",Value=15 });
tlist.Add(new Test() { Key = "B", Value = 10 });
tlist.Add(new Test() { Key = "A", Value = 5 });
tlist.Add(new Test() { Key = "B", Value = 6 });
var rst = (from t in tlist
group t by t.Key
into tt
select new {k= tt.Key, r=tt.Sum(x => x.Value) }).ToList();
这种效果?
这是linq? 应该是这种效果吧 但我不想用linq 想直接用datatable操作
for (int i = 0; i < 10; i++)
{
for (int j = 0; j < 10; j++)
{ if (!list.Contains(i.ToString()))
{
dt.Rows.Add();
list.Add(i.ToString());
dt.Rows[0][1] = j;
}
else
{
continue;
}
}
兩個表循環一下啊,A,b,c用list保存
linq to dataTable了解一下