c# console move string

来源:互联网 发布:淘宝上的人参怎么辨认 编辑:程序博客网 时间:2024/06/05 20:29
using System;using System.Collections.Generic;using System.Linq;using System.Text;namespace ConsoleApplication1{    class Program    {        static void Main(string[] args)        {            Console.ForegroundColor = ConsoleColor.Yellow;            int m = 0;            int n = 0;            Console.Write("zxl");            do            {                switch (Console.ReadKey(true).Key)                {                    case ConsoleKey.UpArrow:                        n = n - 1;                        break;                    case ConsoleKey.DownArrow:                        n = n + 1;                        break;                    case ConsoleKey.LeftArrow:                        m = m - 1;                        break;                    case ConsoleKey.RightArrow:                        m = m + 1;                        break;                }                Console.Clear();                string aa = "";                string bb = "";                for (int a = 0; a < m; a++)                {                    aa += " ";                }                for (int b = 0; b < n; b++)                {                    bb += "\n";                }                Console.Write(bb + aa + "zxl");            }            while (true);        }    }}

原创粉丝点击