The LINQ in Visual Basic and C# is aggregate
来源:
作者:Stand originally
时间:2008-12-21
Tag:
点击:
Resemble be in example of a C# , we solve a problem with a variable that contains two Field. But the example of this and C# is different, you the aggregate function that because be a choice,won't found oneself and kind still waste a loop twice in the gather that all over all previous, and in a dilemma.
Fair for the purpose of, c# still has really so a few action. Unlike VB supports one-way faceless function only in that way, want need only, c# can make them very complex, this makes it OK faceless aggregate function is founded when need.
Var Processes = (from P In Process.GetProcesses() Select New {P.VirtualMemorySize64, p.WorkingSet64});Var Totals4 = Processes.Aggregate(new ProcessTotals() , (Sum, p) =>{Sum.WorkingSet64 = P.WorkingSet64;Sum.VirtualMemorySize64 = P.VirtualMemorySize64; Return Sum;
});
The attention is here, processTotals kind still need to be used. Faceless kind cannot be used to be here, because C# is faceless kind it is immutable. Although of Visual Basic faceless kind can change, but here trashy also, because VB cannot found the faceless function of much travel.
But Visual Basic and C# had strong improvement once upon a time relatively, both sides also has advantage each, let the other side be cheered in insufficient place catch up with.
最新评论共有 0 位网友发表了评论
查看所有评论
发表评论

