- Home /
Removing objects from a list in C#
Hi,
Does anyone know how to remove objects from a list, or all objects in a list in C#???
Thanks
Comment
Best Answer
Answer by Blankzz · Jul 11, 2011 at 12:11 AM
http://msdn.microsoft.com/en-us/library/5cw9x18z.aspx - you can find your answer there. look at remove, removeAll and removeAt
Answer by JoshuaPack · Feb 22, 2014 at 10:58 PM
Adding the list
public List<string> messages = new List<string>();
messages.Add("test1");
messages.Add("test2");
messages.Add("test3");
to clear the list
messages.Clear();
Is it bad to do that? I do not know the etiquette on this. however, I thought some code would be nice for newbies.