Rewriting a statement using LAMBDA(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 7:43 UTC
Read the original article Hit count: 291

Filed under:
|

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

Related posts about lambda

Related posts about c#