c# - Is using linq in this situation overkill -


I'm thinking of a re-factor, but I do not know the end result is overwork only at present I have

  iialit  

Is it forEach

  m_items.ToList () to use linq and / or to be less efficient. ForEach (x => increment + = x.getincurment ());  

Can the cast be an important overhead here? The ToList method is an extension method that is used with LINQ, but forEach method is only the list class.

There is a method in

The main overhead here calls the ToList method, which creates a new list from the archive. There is also a slight overhead because every item has to call a representative.

If you want to use LINQ methods, then the overall method looks more appropriate:

  Public Ink GateInCentment () {Returns M_ts.Egrait (0, (T , I) => T + i.GetIncrement ()); }  

or the sum:

  public int GetIncrementTotal () {return m_items.Sum (i = & gt; i.GetIncrement ()); }  

Either your original version has a little overhead, so if you want the most efficient, just paste it on a simple loop.


Comments

Popular posts from this blog

sql - dynamically varied number of conditions in the 'where' statement using LINQ -

asp.net mvc - Dynamically Generated Ajax.BeginForm -

Debug on symbian -