Search code examples
c#asynchronousentry-point

Can the Main entry-point function be async?


I'm using .NET Framework, and I'm wanting to call an awaitable function in my Main entry-point function.

I'm using the async keyword on the function, but it keeps giving me CS5001 Program does not contain a static 'Main' method suitable for an entry point. Although it doesn't say anything about it not being async.

It seems this error is related to the problem.


Solution

  • Async Main methods were introduced with C#7.1, so if you are targeting that or above, you can use it.