“List.Remove” in C# does not remove item?

后端 未结 6 661
面向向阳花
面向向阳花 2020-12-11 03:04

Hello how can i remove item from generic list here is my code im trying to do it right but i dont know where i make mistake;/

Users us_end = new Users();
for         


        
6条回答
  •  情深已故
    2020-12-11 03:22

    Remove it in place by finding the item inside the remove statement, not via an additional copy:

    List us = ((List)Application["Users_On"]);
    us.Remove(us.FirstOrDefault(u => u.ID == (int)Session["Current_Id"]));
    Application["Users_On"] = us;
    

提交回复
热议问题