如何从文本框中删除某些字符集

时间:2019-06-27 06:25:47

标签: c#

好的,所以我遇到一个问题,我的转换器出于某种原因为程序的某些用户在输出文本框中添加了字符“%22”。我所需要的是我可以放入计时器中的内容,该计时器可以检测文本框中是否检测到“%22”,如果检测到,它将被删除(如果在单词中间,则不留空格)

if (metroTextbox2.Text.Contains("%22")
{
    metroTextbox2.Text.Remove("%22");
}

(上面的代码无法正常工作。它在代码“ metroTextbox2.Text.Remove(“%22”);“上的(”%22“)下留下错误

2 个答案:

答案 0 :(得分:0)

Remove获取int参数而不是字符串。 请改用String.Replace方法。

metroTextbox2.Text = metroTextbox2.Text.Replace("%22", string.Empty);

答案 1 :(得分:0)

请改为使用class ComponentClass { classMethod() { function funcInMethod() { console.log('this in in the function funcInMethod defined and called from the method class: ', this); } funcInMethod(); } } var classInstance = new ComponentClass(); classInstance.classMethod(); // logged: > undefined // expected: > window,而不要使用REMOVE

REPLACE
相关问题