If you can convert to using List<> rather than LinkedList<> then you can use the RemoveAll() operation. Pass an anonymous delegate like this;
List<string> list = new List<string>()
{
"Fred","Joe","John"
};
list.RemoveAll((string val) =>
{
return (0 == val.CompareTo("Fred"));
});
All this is using Linq extensions.
If you can't convert to using a list then you can use the ToList<>() method to convert it. But you'll then have to do some clear and insertion operations. Like this;
LinkedList<string> str = new LinkedList<string>();
str.AddLast("Fred");
str.AddLast("Joe");
str.AddLast("John");
List<string> ls = str.ToList();
ls.RemoveAll((string val) => val.CompareTo("Fred") == 0);
str.Clear();
ls.ForEach((string val) => str.AddLast(val));
If all this still isn't palatable then try doing a copy of the LinkedList like this;
LinkedList<string> str = new LinkedList<string>();
str.AddLast("Fred");
str.AddLast("Joe");
str.AddLast("John");
LinkedList<string> strCopy = new LinkedList<string>(str);
str.Clear();
foreach (var val in strCopy)
{
if (0 != val.CompareTo("Fred"))
{
str.AddLast(val);
}
}
I hope that helps.