Removing Items in a List While Iterating Through It with For Each Loop

前端 未结 7 2237
小鲜肉
小鲜肉 2021-01-17 09:56

I have a list named NeededList I need to check each item in this list to see if it exists in my database. If it does exist in the database I need to remove it

7条回答
  •  日久生厌
    2021-01-17 10:00

    How about this (no iteration needed):

    NeededList = (NeededList.Where(Function(Needed) IsNeeded(Needed)).ToList
    
    Function IsNeeded(Needed As ...) As Boolean
        ...
        Return Not dr.HasRows
    End Function
    

提交回复
热议问题