I usually need to write custom lambda expressions during debugging.
As an example:
(new Func<int, string>(x => $"{commandParameters[x].ParameterName} : {commandParameters[x].Value}"))(2)
or a shorter one:
(new Func<int, string>(x => x.ToString()))(2)
or
((Func<int, string>)(x => x.ToString()))(2)
I'd like to know the simplest form that we can write such expressions so that they can be evaluated in Watch
window.
Omitting the Func
construction we would have (x => x.ToString())(2)
which is much more readable but it won't be evaulated due to CS0149: Method name expected
Lovely Candidates:
(x => x.ToString())(2)
((int x) => x.ToString())(2)