喵喵是个小程序员 2019-08-17 17:41 采纳率: 71.4%
浏览 228

求助:C#事件练习,想做一个可以在控制台控制移动的字符,不知道用什么事件触发

只写了这么点,也不知道是不是该用keyEventArgs

using System;
using System.Windows.Forms;

namespace 会动的方块
{
    class Program
    {
        static void Main(string[] args)
        {
            int[,] map = new int[10, 10];
            KeyEventArgs keyEventArgs = new KeyEventArgs(Keys1);
            Block block1 = new Block();
            Console.Read();
        }
    }
    class Block
    {
        public int Block_x { get; set; } = 1;
        public int Block_y { get; set; } = 1;
        public void Drawer()
        {
            Console.Clear();
            Console.SetCursorPosition(this.Block_x, this.Block_y);
            Console.Write("■");
        }
    }
}

keyEventArgs里面全都是方法,没有事件。。。

  • 写回答

2条回答 默认 最新

  • threenewbee 2019-08-17 23:50
    关注

    没有这样的事件,可以用 Console.ReadKey() 得到输入的按键,自己写一个事件触发

    评论

报告相同问题?

悬赏问题

  • ¥15 MCNP里如何定义多个源?
  • ¥20 双层网络上信息-疾病传播
  • ¥50 paddlepaddle pinn
  • ¥20 idea运行测试代码报错问题
  • ¥15 网络监控:网络故障告警通知
  • ¥15 django项目运行报编码错误
  • ¥15 请问这个是什么意思?
  • ¥15 STM32驱动继电器
  • ¥15 Windows server update services
  • ¥15 关于#c语言#的问题:我现在在做一个墨水屏设计,2.9英寸的小屏怎么换4.2英寸大屏