C# 字符串替换在asp.net中不起作用
我认为两者都是一样的,但第一句话不起作用。第二个是。C# 字符串替换在asp.net中不起作用,c#,replace,C#,Replace,我认为两者都是一样的,但第一句话不起作用。第二个是。 请帮我解决这个问题。我假设您没有将字符串的返回值赋值。请将替换为变量。但由于字符串是不可变的,因此必须这样做: string mystring="the are boys"; string[] tags = {"the"}; string[] replace ={"they"} mystring.Replace(tags[0],replace[0]) // is not working mystring.Replace("the","
请帮我解决这个问题。我假设您没有将
字符串的返回值赋值。请将替换为变量。但由于字符串是不可变的,因此必须这样做:
string mystring="the are boys";
string[] tags = {"the"};
string[] replace ={"they"}
mystring.Replace(tags[0],replace[0]) // is not working
mystring.Replace("the","they") // is working
我几乎害怕mystring.Replace(“the”,“they”)//正在工作
-是真的。证实确实不是。。。不清楚OP为什么做出这样的评论。应该有7个左右!不同标题的类似问题:)还有一些问题,如“+1”中的“替换非字符串工作的aps.net”。简明扼要<代码>字符串是不可变的
mystring = mystring.Replace(tags[0],replace[0])