How to throw an exception when the List <T> .RemoveAll method removes nothing?
I have the following line of code:
races.RemoveAll(br => RaceID == br.raceID);
This means removing all races in the race list that match this condition (have the same RaceID) and this line of code works.
However, my question is, how can I throw an exception if NOTHING has been removed?
I want to do:
if (nothing is removed)
{
throw new Exception ("Nothing was removed from the list, check input");
}
+3
source to share