Laurent Debacker
Sep 3, 2018 · 1 min read

The proper way to write your code in C# is

Console.WriteLine(“hello ” + str(await GetId()));

C# async was designed to write async code in procedural way. They succeeded as the procedural way would have been

Console.WriteLine(“hello ” + str(GetId()));

Both are just as readable. It’s also better optimized than creating lambdas for no reason.

Choice of ForEach would also confuse C# developers. There, foreach is used for iteration on collections. In your case, there is no iteration.

Finally, in C#, one would normally suffix any async method name with “Async” to remind the reader that the call is asynchronous. But this is a detail.

    Laurent Debacker

    Written by