Hi i want to create a list based on the search string using predicate expressions.
I have a list of type products contains different names.
List
You don't have to build a predicate here. You can try something like this
List list1 = new List();
list1.Add(new products("sowmya"));
list1.Add(new products("Jane"));
list1.Add(new products("John"));
list1.Add(new products("kumar"));
list1.Add(new products("ramya"));
string input = "aaa+kuma+ram";
List searchStrings =
input.Split(new string[] { "+" }, StringSplitOptions.None)
.Select(s => s.ToLower())
.ToList();
List list2 = (
from p in list1
where searchStrings.Any(s => p.Name.Contains(s))
select p).ToList();
list2 will contain "kumar" and "ramya".