I'm looking for a smart way to find List-Elements with a specific Character in a List of Strings.
I want to find all Strings, wich contains a ?-sign in a List of Strings like: "a?11", "ab12", "bb12", "b?13"
My current solution looks like this:
// Interates through all strings.
foreach (string currentString in listOfStrings)
{
if (currentString.Contains('?'))
{
// Found!
myStrings.Add(currentString);
}
}
Is there a better way to do this job, maybe like:
List<string> myStrings = listOfStrings.Select(z => z.Contains('?')).ToList();
Any ideas?