Check if list contains element that contains a string and get that element

前端 未结 12 2502
抹茶落季
抹茶落季 2020-12-07 10:39

While searching for an answer to this question, I\'ve run into similar ones utilizing LINQ but I haven\'t been able to fully understand them (and thus, implement them), as I

12条回答
  •  抹茶落季
    2020-12-07 11:30

    Many good answers here, but I use a simple one using Exists, as below:

    foreach (var setting in FullList)
    {
        if(cleanList.Exists(x => x.ProcedureName == setting.ProcedureName)) 
           setting.IsActive = true; // do you business logic here 
        else
           setting.IsActive = false;
        updateList.Add(setting);
    }
    

提交回复
热议问题