输出效果如下
代码如下
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
namespace ConsoleOutPut
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void button1_Click(object sender, EventArgs e)
{
int hang;
int lie;
if (!int.TryParse(textBox_Hang.Text, out hang))
{
hang = 0;
}
if (!int.TryParse(textBox_Lie.Text, out lie))
{
lie = 0;
}
//背景颜色
Console.BackgroundColor = ConsoleColor.Blue;
//清空屏幕
Console.Clear();
//设置光标
Console.SetCursorPosition(lie, hang);
//输出内容
Console.WriteLine("时间 -> " + DateTime.Now.ToString());
//改变光标
Console.SetCursorPosition(lie+5, hang+5);
Console.WriteLine("时间 -> " + DateTime.Now.AddMinutes(2).ToString());
}
private void timer1_Tick(object sender, EventArgs e)
{
button1_Click(null, null);
}
}
}
主要是实现了控制台光标定位,清屏 、输出信息
特此记录
anlog
2022年8月19日
最后
以上就是如意胡萝卜最近收集整理的关于c#控制台输出控制的全部内容,更多相关c#控制台输出控制内容请搜索靠谱客的其他文章。
本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
发表评论 取消回复