C# – LINQ Regex ArgumentNullException

Hi, I currently have a small problem with a LINQ Regex Search.

Matches = _employees.FindAll(e => searchPattern.IsMatch(e.JobTitle) || searchPattern.IsMatch(e.EMail) || searchPattern.IsMatch(e.Phone) || searchPattern.IsMatch(e.birth.Year.ToString())); 

It is possible, that JobTitle, E-mail or Phone are null. Is there any way i can keep the LINQ so I don't have to swap to a foreach loop?

It's C#5.0 so i have no Elvis Expression

thanks 🙂

by Jonas_Dralle via /r/csharp

Leave a Reply