本文介绍了用新值替换旧值到字符串中的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
在我的字符串变量中,此代码存储&我想将此字符串
in my string variable this code is stored & I want to replace this string
this.Name = "rptTableReport1"替换为
this.Watermark.Text = "Trial version";字符串变量数据
string variable data
string Reportsetting=this.Bands.AddRange(new DevExpress.XtraReports.UI.Band[] { this.Detail, this.TopMargin, this.BottomMargin}); this.Margins = new System.Drawing.Printing.Margins(0, 100, 100, 42); this.Name = "rptTableReport1"; this.PageHeight = 1100; this.PageWidth = 850; this.TextAlignment = DevExpress.XtraPrinting.TextAlignment.TopJustify; this.Version = "11.1"; this.Watermark.Text="ABC" this.Watermark.Font = new System.Drawing.Font("Verdana", 40F); this.Watermark.ForeColor = System.Drawing.Color.DodgerBlue; this.Watermark.ShowBehind = false; this.Watermark.TextTransparency = 170; ((System.ComponentModel.ISupportInitialize)(this)).EndInit();我使用了以下编码
i have used the following coding
string oldSTR = @" this.Name = ""rptTableReport1""; "; string newSTR = @" this.Watermark.Text = ""TRIAL VERSION"";"; Reportsetting.Replace(oldSTR, newSTR);但不会替换字符串 请告诉正确的方法替换此字符串. 在字符串变量中,我已经有this.Watermark.Text ="VALUE"&我要替换此值如何替换此值? 在此先感谢..
but it will not replace the string please tell right method to replace this string. in string variable i have already this.Watermark.Text =" VALUE" & i want to replace this value how to replace this value? thanks in advance..
推荐答案删除空格,因为它们可能是制表符而不是空格,并且您的查找"将不起作用 Remove the spaces as they could be tabs not spaces and your "find" will not work string oldSTR = @"this.Name = ""rptTableReport1"";"; string newSTR = @"this.Watermark.Text = ""TRIAL VERSION"";"; Reportsetting.Replace(oldSTR, newSTR);
更多推荐
用新值替换旧值到字符串中
发布评论