Reputation: 3875
suppose i have an
List<SomeObject>
List<AnotherObject>
and an extention method that returns SomeObject
Instance when i send it AnotherObject
i need to produce a IList<SomeObject>
from an IList<AnotherObject>
so without linq i wolud do it as
private List<SomeObject> ToListOfProductEntry(List<AnotherObject> list)
{
List<SomeObject> result = new List<SomeObject>();
foreach (var obj in list)
{
result.Add(obj.ToSomeObject()); // ToSomeObject() is an extention method
}
return result ;
}
how can achive the same result using LINQ, i dont use LINQ alot so i am not familiar with it.
Upvotes: 0
Views: 38