最佳答案
我是异步编程的新手,所以在浏览了一些异步示例代码之后,我想编写一个简单的异步代码
我创建了一个简单的 Winformation 应用程序,并在表单中编写了以下代码
private Task<string> methodAsync() {
Thread.Sleep(10000);
return "Hello"; //Error: Cannot implicitly convert type 'string' to 'System.Threading.Tasks.Task<string>'
}
private async void button1_Click(object sender, EventArgs e)
{
string s = await methodAsync();
MessageBox.Show(s);
}
有没有人能把灯放在这里。