Advertisement
2629881

Untitled

Jul 25th, 2018
183
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.33 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.             string defaultString = "A moving line";
  15.             while (true)
  16.             {
  17.                 int i = 0;
  18.                 if (i % 2 == 0)
  19.                 {
  20.                     for (int a = 7; a <= 20; a++)
  21.                     {
  22.                         WriteTextInPosition(defaultString, a);
  23.                         Thread.Sleep(42);
  24.                     }
  25.                 }
  26.                 i++;
  27.                 if (i % 2 != 0)
  28.                 {
  29.                     for (int a = 19; a > 7; a--)
  30.                     {
  31.                         WriteTextInPosition(defaultString, a);
  32.                         Thread.Sleep(42);
  33.                     }
  34.                 }
  35.             }
  36.         }
  37.        
  38.         public static void WriteTextInPosition(string text, int bot)
  39.         {
  40.                 Console.Clear();
  41.                 for (int i = 1; i <= bot; i++)
  42.                 {
  43.                     Console.WriteLine();
  44.                 }
  45.                 Console.WriteLine(String.Format("{0," + ((Console.WindowWidth / 2) + (text.Length / 2)) + "}", text));
  46.         }
  47.     }
  48. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement