I'm just learning .NET Core and I'm trying to make sense of the way the Main()
function is coded. When I see code examples of .NET core prorgrams, this is what I see:
static Task Main(string[] args) =>
CreateHostBuilder(args).Build().Run();
My questions are:
Why return a type of
Task
from theMain()
, and how/where is a type ofTask
being instantiated? Is this something done in the background by the framework?Why use a lambda expression for the body of the
Main()
function? From all the documentation I've read about Lambda expressions, they are used either for delegates or expression trees. Neither of those are present here.