-5
我需要將字符串「DT1OutPassFail」更改爲「DT4OutPassFail」。我需要在輸入字符串中找到「DT1」並將其替換爲「DT4」以獲取輸出字符串。我需要使用c#來做到這一點。 「DT1」是textbox1中的值,「DT4」是textbox2中的值。我嘗試了以下選項。但它的工作。使用c替換一個詞的一部分#
string input = "DT1OutPassFail";
string newstring;
newstring = input.Replace(textbox1.Text, textbox2.Text);
newstring = Regex.Replace(input,textbox1.Text, textbox2.Text);