Rewriting a statement using LINQ(C#)
Posted
by Thinking
on Stack Overflow
See other posts from Stack Overflow
or by Thinking
Published on 2010-04-13T07:36:58Z
Indexed on
2010/04/13
8:03 UTC
Read the original article
Hit count: 136
Is it possible to write the folowing using lambda(C#)
private static void GetRecordList(List<CustomerInfo> lstCustinfo)
{
for (int i = 1; i <= 5; i++)
{
if (i % 2 == 0)
lstCustinfo.Add(new CustomerInfo { CountryCode = "USA", CustomerAddress = "US Address" + i.ToString(), CustomerName = "US Customer Name" + i.ToString(), ForeignAmount = i * 50 });
else
lstCustinfo.Add(new CustomerInfo { CountryCode = "UK", CustomerAddress = "UK Address" + i.ToString(), CustomerName = "UK Customer Name" + i.ToString(), ForeignAmount = i * 80 });
}
}
© Stack Overflow or respective owner