I apologize for posting such a seemingly simple question. I know there are many similar questions already posted (and I have looked at many of these before posting my question), but I struggle to apply the answers to my situation. I am relatively new to C#, and would appreciate your input and help.
How can I compare my 2 Lists
with a foreach
loop, and create a new List
with the records found that does not exist in my comparison?
Below is the code outline I already have, and comments of what needs to happen:
private void updateHolidays()
{
List<Holiday> localHolidays = getLocalHolidays();
List<Holiday> remoteHolidays = getRemoteHolidays();
List<Holiday> holidayDifference = new List<Holiday>();
foreach (Holiday holiday in remoteHolidays)
{
if (true) // holiday does not exist in localHolidays
{
// add holiday to holidayDifference
holidayDifference.Add(holiday);
}
}
createNewHolidays(holidayDifference);
}
Thank you in advance!