题目:
界面:
代码:
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace 考试题目汇总
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void textBox输入_KeyPress(object sender, KeyPressEventArgs e)
{
if ((e.KeyChar >= 0x0041 && e.KeyChar <= 0x005A) | (e.KeyChar >= 0x0061 && e.KeyChar <= 0x007A))
{
}
else
{
e.Handled = true;
}
}
private void button1_Click(object sender, EventArgs e)
{
string a = "";
if (string.IsNullOrEmpty(textBox输入.Text.ToString()))
{
MessageBox.Show("输入字符串不能为空!");
}
else
{
foreach (char c in textBox输入.Text.ToString())
{
if (c >= 'A' && c <= 'Z')
{
a += char.ToLower(c);
}
else if (c >= 'a' && c <= 'z')
{
a += char.ToUpper(c);
}
}
textBox输出.Text = a;
}
}
}
}
2017年的高级程序设计考试题目,保真,2024年考了一道类似的。