0

I am trying to remove a customer from a list, as shown below.

customerList.Remove(customer);

I display the entire list before and after this is run, and it shows that nothing is changed. I looked at another post here: "List.Remove" in C# does not remove item? but I wasn't able to discern how this solution applied to mine.

I know that I need to grab the object directly from the list, and not a copy of it. I just am not sure this is the same case, and if it is I would appreciate some help!

string file = @"C:~\bin\Debug\Customer.xml";
List<Customer> customerList = new List<Customer> { };
XmlSerializer customerSerializer = new XmlSerializer(customerList.GetType());
using (StreamReader customerStreamReader = new StreamReader(file))
{
    customerList = (List<Customer>)customerSerializer.Deserialize(customerStreamReader);
}
Console.WriteLine();
customerList.Remove(customer);
Daxtron2
  • 1,239
  • 1
  • 11
  • 19
Mark Hollis
  • 151
  • 1
  • 13

0 Answers0