LINQ equivalent of foreach for IEnumerable

后端 未结 22 2247
夕颜
夕颜 2020-11-21 22:54

I\'d like to do the equivalent of the following in LINQ, but I can\'t figure out how:

IEnumerable items = GetItems();
items.ForEach(i => i.DoS         


        
22条回答
  •  北海茫月
    2020-11-21 23:23

    Yet another ForEach Example

    public static IList MapToDomain(IList addresses)
    {
        var workingAddresses = new List();
    
        addresses.Select(a => a).ToList().ForEach(a => workingAddresses.Add(AddressModelMapper.MapToDomain(a)));
    
        return workingAddresses;
    }
    

提交回复
热议问题