LINQ qusetion

  • Thread starter Thread starter essamce
  • Start date Start date
E

essamce

Guest
hi

public static IEnumerable<MCircle> ToSimple2DCircles(this IEnumerable<MCircle> circles, List<MLayer> workingLayers, int id)
{
var collection = from c in circles
from wl in workingLayers
where c.Layer.Name == wl.LayerName
select new { c.Radius, wl.LayerCategory };

foreach (var elm in collection)
{
id++;
yield return new MCircle
(id, elm.Radius, elm.LayerCategory);
}
}



is it possible to get rid of foreach,

and do something like

from c in circles
from wl in workingLayers
where c.Layer.Name == wl.LayerName
yield return new MCircle (id, elm.Radius, elm.LayerCategory);

Continue reading...
 
Back
Top