As per this post, the top voted answer suggested that we can use async directly in main. Or I misunderstood it?
Can't specify the 'async' modifier on the 'Main' method of a console app
My main class:
public class Program
{
public static async Task Main(string[] args)
{
ApproveEvents ap = new ApproveEvents();
List<MyModel> result = new List<MyModel>();
result = await ap.ApproveAsync();
if (result.count > 0)
{
//do something here
}
}
}
And,
public class ApproveEvents
{
public async Task<List<MyModel>> ApproveAsync()
{
//blah blah
}
}
Visual Studio 2017 is complaining about no Main method for an entry point.
How should I resolve this?
async Task Main is available in C# 7.1. You can change it in build properties (the default is the latest major version, which is 7.0)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With