In my project I’m having a StringBuilder which takes the selected value of dropdown lists.
StringBuilder builder = new StringBuilder();
builder.Append(ddl_model.SelectedValue);
builder.Append(ddl_language.SelectedValue);
foreach (string str in list)
{
if (str.Contains(builder.ToString()))
{
lstpdfList.Items.Add(str);
}
}
It works with one value. I would like to make that I can check if contains two or more words.
I have a file like PM12_Manual_Rev1_EN . Now I can find if it contains PM12. But there is a lot of them. So I would like to check if contains PM12 + EN.
1) Don’t call builder.ToString() inside the foreach, it will rebuild the string everytime, and it defeats the performance purpose of StringBuilder.
2) Don’t use a StringBuilder, use a List in which you store the words you want to match for, if each selected value may contain several words, split them: