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

Popular posts from this blog

c++ - Convert big endian to little endian when reading from a binary file -

C#: Application without a window or taskbar item (background app) that can still use Console.WriteLine() -

unicode - Are email addresses allowed to contain non-alphanumeric characters? -