I am implementing the following code to remove an item from a list
// RemoveRole is a member function in a class for Person
// roles is defined as
// List<PersonOrganisationRoleModel> roles;
// And properly populated prior to this function call
public void RemoveRole(string RoleName)
{
// I am creating an object that needs to be matched in the list
PersonOrganisationRoleModel role = new PersonOrganisationRoleModel(OrganisationID, PersonID, RoleName)
// "role" is now properly constructed, and is matching an exact copy of one of the objects in "roles"
// the expectation now is the the object "role" must be matched with one of the objects in "roles",
// and that one be removed
roles.Remove(role);
}
But the "Remove" function call on the "roles" list does not remove the item in the list that contains the exact same values.
My understanding is that this is supposed to work (it is just the inverse of List.Add