N
N
NkDev2020-12-07 01:11:22
C++ / C#
NkDev, 2020-12-07 01:11:22

C#. How to change the lines displayed in the console in a console application?

I am just starting to learn C#. Help implement the following functionality.

There is a code:

using System;

class Program
{
    static void Main() {
        Console.WriteLine("Hello ");
        Console.WriteLine("Привет ");

        Console.ReadKey();
     }
}


This program prints two lines to the console and waits for the user to press a key.
I need that after these two lines are printed, but before the program finishes, after, say, 3 seconds, the word "world" is added to the first line, and then after another 3 seconds the word "world" is added to the second line.

I would be very grateful if someone could tell me the code on how to do this.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Alexander, 2020-12-07
@NkDev

using System;
using System.Threading;

namespace ConsoleApp1
{
    class Program
    {
        static void Main(string[] args)
        {
            Console.WriteLine("Hello ");
            Console.WriteLine("Привет ");
            Thread.Sleep(3000);
            Console.SetCursorPosition(6, 0);
            Console.WriteLine("world!");
            Thread.Sleep(3000);
            Console.SetCursorPosition(7, 1);
            Console.WriteLine("мир");
        }
    }
}

Thank you!

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question