实验6-C#多项目开发

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();
        }
    }
}

程序运行:


评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值