Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 500829
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T06:07:38+00:00 2026-05-13T06:07:38+00:00

I have a generic list that I’m removing items out of using List.Remove(Object) .

  • 0

I have a generic list that I’m removing items out of using List.Remove(Object). I have been removing items but whenever I get to the fifth item I’m removing it fails and does not remove it from the list. It doesn’t seem to matter what I’m removing but everytime I try to remove five items it fails on the fifth item.

What could be causing this? Looking at the documentation for List(Of T).Remove, it doesn’t specify what algorithm they’re using to remove the item.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-13T06:07:39+00:00Added an answer on May 13, 2026 at 6:07 am

    Remove is going to match based on calling .Equals on your objects. By default for a given object it’ll only match the same object. If you want two objects with the same properties to be considered equal even if they’re not the same object, you need to override the Equals method and put your logic there.

    However, another good option is to use RemoveAll and pass in an anonymous delegate or a lambda expression with the criteria you’re looking for. E.g.:

    customers.RemoveAll(customer => customer.LastName.Equals(myCustomer.LastName));
    

    Of course that only works if you really want to remove all the matching items, and/or if you’re certain there will only be one that matches.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to figure out how to traverse a generic list of items that
I need to have a generic list type Object as a parameter ,which whenever
I have a generic list class that implements a particular interface. The list items
I have a generic linked-list that holds data of type void* I am trying
I have a class Team that holds a generic list: [DataContract(Name = TeamDTO, IsReference
I have two threads, a producer thread that places objects into a generic List
I have a generic Print method that iterates over a list and simply prints
I have a Generic List object which hold below table as its own value.
Let's say I have a generic Object class, and a generic List class. I
I have created a subclass of a generic list so that I could implement

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.