assign value using linq

后端 未结 4 1700
孤城傲影
孤城傲影 2020-12-07 18:51
public class Company
{
    public int id { get; set; }
    public int Name { get; set; }
}

List listofCompany = new List();

4条回答
  •  离开以前
    2020-12-07 19:34

    It can be done this way as well

    foreach (Company company in listofCompany.Where(d => d.Id = 1)).ToList())
                    {
                        //do your stuff here
                        company.Id= 2;
                        company.Name= "Sample"
                    }
    

提交回复
热议问题