1、使用三个窗体模块文件及一个标准模块文件,使输入字符串以不同形式显示。
程序设计:
程序代码:
//定义公共类
namespace WindowsFormsApplication1
{
class PublicClass
{
public string fnClsSpace(string s)//去除字符串空格
{
string strReturn = s.Replace(" ", "");
return strReturn;
}
public string fnInverSt(string s)//字符串反向输出
{
char[] w=s.ToCharArray();
Array.Reverse(w);
return new string(w);
}
}
}
namespace WindowsFormsApplication1
{
//清除空格窗体
public partial class frmCls : Form
{
public frmCls()
{
InitializeComponent();
}
private void button1_Click(object sender, EventArgs e)
{
PublicClass puC=new PublicClass();
textBox2.Text = puC.fnClsSpace(textBox1.Text);
}
private void button2_Click(object sender, EventArgs e)
{
this.Close();
frmSel frmSel = new frmSel();
frmSel.Show();
}
}
}
namespace WindowsFormsApplication1
{
//反向排列窗体
public partial class frmInver : Form
{
public frmInver()
{
InitializeComponent();
}
private void button1_Click(object sender, EventArgs e)
{
PublicClass puC=new PublicClass();
textBox2.Text = puC.fnInverSt(textBox1.Text);
}
private void button2_Click(object sender, EventArgs e)
{
this.Close();
frmSel f = new frmSel();
f.Show();
}
}
}
namespace WindowsFormsApplication1
{
//选择窗体
public partial class frmSel : Form
{
public frmSel()
{
InitializeComponent();
}
private void button1_Click(object sender, EventArgs e)
{
if (radioButton1.Checked == true)
{
this.Hide();
frmInver f1 = new frmInver();
f1.Show();
}
if (radioButton2.Checked == true)
{
this.Hide();
frmCls f2 = new frmCls();
f2 = new frmCls();
f2.Show();
}
}
private void button2_Click(object sender, EventArgs e)
{
Close();
}
}
}
程序运行:


被折叠的 条评论
为什么被折叠?



