用新值替换旧值到字符串中

编程入门 行业动态 更新时间:2024-10-26 10:28:07
本文介绍了用新值替换旧值到字符串中的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

在我的字符串变量中,此代码存储&我想将此字符串

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

更多推荐

用新值替换旧值到字符串中

本文发布于:2023-08-01 08:49:41,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1266992.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:字符串   用新值   旧值到

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!