Advertisement
2629881

Untitled

Jul 25th, 2018
125
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.42 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Threading.Tasks;
  6. using System.Threading;
  7.  
  8. namespace ConsoleApp11
  9. {
  10.     class Program
  11.     {
  12.         static void Main(string[] args)
  13.         {
  14.             while (true)
  15.             {
  16.                 string defaultString = "A moving line";
  17.                 for (int i = 0; i < 2; i++)
  18.                 {
  19.                     if (i == 0)
  20.                     {
  21.                         for (int a = 7; a <= 20; a++)
  22.                         {
  23.                             WriteTextInPosition(defaultString, a);
  24.                             Thread.Sleep(42);
  25.                         }
  26.                     }
  27.                     if (i == 1)
  28.                     {
  29.                         for (int a = 19; a > 7; a--)
  30.                         {
  31.                             WriteTextInPosition(defaultString, a);
  32.                             Thread.Sleep(42);
  33.                         }
  34.                     }
  35.                 }
  36.             }
  37.         }
  38.        
  39.         public static void WriteTextInPosition(string text, int bot)
  40.         {
  41.                 Console.Clear();
  42.                 for (int i = 1; i <= bot; i++)
  43.                 {
  44.                     Console.WriteLine();
  45.                 }
  46.                 Console.WriteLine(String.Format("{0," + ((Console.WindowWidth / 2) + (text.Length / 2)) + "}", text));
  47.         }
  48.     }
  49. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement