Sweta Sinha

Sweta Sinha

  • NA
  • 51
  • 42.2k

Search a string within a string

Mar 2 2015 1:52 AM
Hi,
 
I have a search box and want to search a string from a  string.i.e,
Suppose, str[]= abf,fghi,acb,stabu
and if I search for "ab",then it should display "abf" and "stabu"
 
My Code:-
 
List<string> selectedValues = new List<string>(); 
foreach (string str in completeList)
{
   if(str.Contains(filterWith))   //filterWith is the sequence of characters to be searched
   selectedValues.Add(str);
}
 

Answers (7)