Await example in C#
using System;
using System.Threading.Tasks;
class Program {
private static string result="test123";
static void Main() {
SaySomething();
Console.WriteLine(result);
}
static async Task<string> SaySomething() {
await Task.Delay(5);
Console.WriteLine("test");
result = "Hello world!";
Console.WriteLine(result);
return “Something”;
}
}
Output
test123
test
Hello world!