Can you solve this async C# problem?

preview_player
Показать описание
Can you solve this async/await problem? Check below for a copy of the code.

#shortsvideo #dotnet #dotnetprogramming #dotnet6 #programming #csharp #programmingforbeginners #csharp #csharptutorial #csharpdotnet #aspnetcore #programmingtutorials #aspnetcore #dotnet #dotnet6 #dotnetprogramming #programming #programmingforbeginners #programmingtutorials #learnprogramming #learnprogrammingonyoutube #learntocode

Great Explainers:

Code from the video:
using System;
class Program
{
private static string result;

static void Main()
{
SaySomething();
Console.WriteLine(result);
}

static async Task{leftanglebracket}string{rightanglebracket}SaySomething()
{
Thread.Sleep(5);
result = "Hello world!";
return "Something";
}
Рекомендации по теме
Комментарии
Автор

Await keyword will make that function can go to next line after that function called. Thread.sleep will not release the async func, all async functions should have await, its a compiler error

manohargoud
Автор

Empty string.
Thank you for the trick question. 😊

fieryscorpion