第1个回答 2013-08-11
可以使用if判断键盘输入字符,使用return命令中止程序运行。代码: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 WindowsFormsApplication1
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
} private void textBox1_TextChanged(object sender, EventArgs e)
{
string nowString = this.textBox1.Text[this.textBox1.Text.Length - 1].ToString();
if (nowString == this.textBox2.Text)
{
this.Dispose();
}
}
}
}
结果 输入g则中止运行