Please consider the following:
private static string Sub(int anInt)
{
return anInt.ToString();
}
private static void Test()
{
const int anInt = 100;
Func<int,string> aFunc = Sub;
//why does Task<string> task = Task.Run(aFunc(anInt)); not compile?
Task<string> task = Task.Run(() => aFunc(anInt));
Console.WriteLine(task.Result);
}
This code compiles fine. Why does the line
Task<string> task = Task.Run(aFunc(anInt));
not compile?
Is there a way to pass in a delegate invocation without a Lambda expression?
What am I missing?