Change the foreach loop into the LINQ query
string one = "1"; //an exaplme string two = "2"; //an exaplme foreach (var item in myStringsList) { string[] splitted = item.Split(new char[] { '_' }, StringSplitOptions.RemoveEmptyEntries); if(splitted.Length >= 3) { if(splitted[1] == one && splitted[2] == two) { resultList.Add(item); } } }