Can't specify the 'async' modifier on the 'Main' method of a console app

后端 未结 16 2018
后悔当初
后悔当初 2020-11-21 07:44

I am new to asynchronous programming with the async modifier. I am trying to figure out how to make sure that my Main method of a console applicati

16条回答
  •  被撕碎了的回忆
    2020-11-21 08:38

    Newest version of C# - C# 7.1 allows to create async console app. To enable C# 7.1 in project, you have to upgrade your VS to at least 15.3, and change C# version to C# 7.1 or C# latest minor version. To do this, go to Project properties -> Build -> Advanced -> Language version.

    After this, following code will work:

    internal class Program
    {
        public static async Task Main(string[] args)
        {
             (...)
        }
    

提交回复
热议问题