通过泛型操作实现子窗体的不同操作

实现效果:

  

  

  

知识运用:

  通过泛型方法的重载实现调用窗体与提示窗体分开编写

实现代码:

        public void FormOperate<T>(){
            Form2 frm_2 = new Form2();  //创建Form2窗体对象
            frm_2.ShowDialog();     //以对话框形式显示Form2窗体
        }
        public void FormOperate<T>(string strError) {
            MessageBoxIcon mbi = MessageBoxIcon.Error;  //创建提示框中图标对象
            MessageBox.Show(strError,"提示",MessageBoxButtons.OK,mbi);  //显示错误提示框
        }
原文地址:https://www.cnblogs.com/feiyucha/p/10089218.html