I have a function that returns Func<T,TResult>
. I want to return multiple funcs in a single func with ||
of one another.
Below func is just sample but my actual code contains multiple lines of code snippet in func. In which I have to check for each value of comma separated string. Like below function there are multiple functions which returns Func<string, bool>. And all these func will combine as && for further use
public static Func<string, bool> GetData(string request)
{
var data = request.Split(',');
//This func is just sample but my actual code contains multiple lines of code snippet in func. In which I have to use each value of comma separated string.
Func<string, bool> selector = str => str.ToUpper() == data[0] || str => str.ToLower() == data[0] ;
for(int i = i; i < data.Length; i++)
{
Func<string, bool> selector1 = str => str.ToUpper() == data[i] || str => str.ToLower() == data[i] ;
// something like this func || func1 || func2 || func3... and so on
selector = selector || selector1;
}
return selector;
}