for (int i = 0; i < holidaylist.Count; i++) { for (int j = i + 1; j < _holidayviews.Count; j++) { if (holidaylist[i].Date == holidaylist[j].Date) { throw new Exception("Holiday Date cannot be same"); } }
It can be something like:
if (holidaylist.Select(h => h.Date).Distinct().Count() != holidaylist.Count) { throw new Exception("Holiday Date cannot be same"); }
holidaylist
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)