C#函数 把 对象作为参数传递

来源:互联网 发布:ip和域名的区别 编辑:程序博客网 时间:2024/05/05 06:55

 

        private void btnGetPrintingName_Click(object sender, EventArgs e)        {           string strRegText=this.textBoxRegText.Text;           Regex reg = new Regex(strRegText, RegexOptions.Singleline);                        //文件名顺序           IList<FileInfo> ds = m_ds;            //Object 是引用,textBox改变了           ReplaceName(ds, reg, "", textBoxPrintingNameAndName);        }        private void ReplaceName(IList<FileInfo> ds, Regex reg, string replaceMant, TextBox textBox) {            StringBuilder strBuilder = new StringBuilder();            foreach (FileInfo item in ds)            {                strBuilder.Append(reg.Replace(item.Name, replaceMant)+"\t"+item.Name+Environment.NewLine);                            }            textBox.Text=strBuilder.ToString();          }


 

对象 要用new 创建,才是"值"传递.;string是例外
原创粉丝点击