2

This line in main

Task.Run(f);

with this function in the same class Program

static int f() { return 0; }

causes this compile error (there are no other methods called f in Program):

CS0121 The call is ambiguous between the following methods or properties: 'Task.Run<TResult>(Func<TResult>)' and 'Task.Run(Func<Task>)'

Isn't it obviously Func<int> and not Func<Task>?

However, all of these work:

Task.Run(() => 0);
Task.Run(() => f());
Task.Run(async () => f());
Victor
  • 743
  • 1
  • 5
  • 16
  • I was about to say this is different from the question marked as a duplicate, as that one has an error message about `Action` and `Func`, but now, I realize that this is the same in that only the return type differs in `Func` and `Func`. – Victor Sep 07 '17 at 18:07

0 Answers0