Is there any difference between
int i = 0;
var myItems = (from source in datasource
select new MyObject
{
LabelId = i++,
Label = source.SourceName,
Data = source.TotalCount
}).ToList();
and
int i = 0;
List<MyObject> myItems = new List<MyObject>();
foreach (var source in datasource)
{
MyObject myItem = new MyObject()
{
Label = item.SourceName,
LabelId = i++,
Data = item.TotalCount
};
myItems.Add(myItem);
}
When dealing with performance / complexity time ?
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…