Is there a better way to write this? I feel like I’m getting rusty with C# after doing a lot of JavaScript lately. Can this be improved?
foreach (var item in this.CartItems)
{
if (item.EffectivePrice != null)
{
this.CartItems[this.CartItems.IndexOf(item)].EffectivePrice =
CurrencyHelper.GetLocalizedCurrency(item.EffectivePrice);
}
}
Well, you could write it in LINQ query syntax with a
fromand awhere, but I’m not sure it is a big change; I’d be more interested in knowing if the lookup is unnecessary:to:
Other than that, I’m not sure it is worth the bother of changing it; I’d probably leave it as: