c# - LINQ? Refactoring foreach -
is there better way write this? feel i'm getting rusty c# after doing lot of javascript lately. can improved?
    foreach (var item in this.cartitems)     {         if (item.effectiveprice != null)         {             this.cartitems[this.cartitems.indexof(item)].effectiveprice =                  currencyhelper.getlocalizedcurrency(item.effectiveprice);         }     }      
well, could write in linq query syntax from , where, i'm not sure big change; i'd more interested in knowing if lookup unnecessary:
this.cartitems[this.cartitems.indexof(item)].effectiveprice =              currencyhelper.getlocalizedcurrency(item.effectiveprice);   to:
item.effectiveprice = currencyhelper.getlocalizedcurrency(item.effectiveprice);   other that, i'm not sure worth bother of changing it; i'd leave as:
foreach (var item in this.cartitems) {     if (item.effectiveprice != null) {         item.effectiveprice = currencyhelper.getlocalizedcurrency(item.effectiveprice);     } }      
Comments
Post a Comment