private void textBox1_TextChanged(object sender, EventArgs e)
{
int a = 0;
int beijing = 18;
int shanghai = 20;
int tianjing = 11;
int shenyang = 0;
switch ("textBox1.Text")
{
case "北京":
a = beijing;
if (a < 20)
beijing++;
break;
case "上海": a = shanghai;
if (a < 20)
shanghai++;
break;
case "天津": a = tianjing;
if (a < 20)
tianjing++;
break;
case "沈阳": a = shenyang;
if (a < 20)
shenyang++;
break;
b = a;
}
}
private void button1_Click(object sender, EventArgs e)
{
if (a< 20)
就像这样 但是把a放到上面还是不行