I have a hashset of strings that contain lognames called pidLogsLines. From this hashset I want to filter out logs that only contain strings from another hashset called pidList and put these logs inside a new hashset called filesWithPid. I am doing this with two loops:
var filesWithPid = new HashSet<string>(StringComparer.OrdinalIgnoreCase);
foreach(var logname in pidLogsLines)
{
foreach(var pid in pidList)
{
if (logname.Contains(pid))
{
filesWithPid.Add(logname);
}
}
}
Is this the optimal way to do it? I am new to C# so I am not aware of any elaborate faster ways to do it