I’m in the process of learning LINQ and would like some help the following method. How can I rewrite the following method to use LINQ?
private bool IsInList(string file, List<FileInfo> excelList)
{
if (excelList != null && excelList.Count > 0)
{
foreach (FileInfo f in excelList)
{
if (string.Compare(f.FullName, file, StringComparison.OrdinalIgnoreCase) == 0)
{
return true;
}
}
}
return false;
}
I’d change the second parameter to accept an
IEnumerable<FileInfo>instead so you’re not limiting yourself to just lists.