I noticed this function in a .NET project I am working on.
private static void RemoveAllElements(ref List<int> listToBeRemoved)
{
foreach (var i in listToBeRemoved)
{
listToBeRemoved.Remove(i);
}
}
Is this the quickest way to remove all elements from a list? I also noticed this function doesn't catch any exceptions. Should I change this? This is in existing code.