'How to wait or delay a code in my CS code

I want to create a waiting sequence or the lines appear after a specified time.

I tried Task.Sleep(number); and await Task.Delay(2000); but no.. nothing works.

VSC says The name 'Task' does not exist in the current context



Solution 1:[1]

You need to add async Task, without testing it something like should work:

using System.Threading.Tasks;

namespace Simple;

class Program
{
    public static async Task Main()
    {
        await Task.Delay(2000);
    }
}

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Maytham Fahmi