How do I pass a anon function in the parameter to be ran in a select statement?
public IEnumerable<string> Tokenize(Func<string> tokenFunc = null)
{
IEnumerable<string> tokens = Regex.Split(INPUT, @"(\d+|&|\||\(|\))").Where(x => string.IsNullOrEmpty(x) == false);
if (tokenFunc != null)
{
tokens = tokens.Select(tokenFunc);
}
}
I get the error:
The type arguments for method 'Enumerable.Select(IEnumerable, Func)' cannot be inferred from the usage. Try specifying the type arguments explicitly
What am I doing wrong?
I want to call it like this:
MyViewObj.Tokenize( (x) => { if(x=='1') return 1; else return 0; });