我想将这两个“丑陋的” for 循环转换为LINQ表达式。谁能帮我吗?我对LINQ很新。提前谢谢!
foreach (Edge edge in distinctEdge)
{
var c = 0;
foreach(Edge e in EdgeList)
{
if(e.target == edge.target && e.source == edge.source)
{
c++;
}
}
edge.value = c;
}
答案 0 :(得分:8)
使用ReSharper:
gtk_text_buffer_serialize()
答案 1 :(得分:4)
易于阅读和理解的东西
var value=(from edge in distinctEdge
join e in EdgeList
on edge.Target equals e.Target
and e.source equals edge.source
select edge ).Count();