用一个空格替换" - "?替换方法不起作用

Riv*_*asa 0 c# string replace

我正在制作一个个人程序,在其中,我得到一些字符串,可能有一个空格连字符空格.或类似的东西:" - "而我要做的就是用一个空格替换它.现在,问题是,当我尝试使用c#库中的替换方法时,它似乎没有做任何事情.这是我试过的:

string firsttext = firsttextbox.Text.ToLower();
string name = firsttext.Replace(" - ", " ");
Run Code Online (Sandbox Code Playgroud)

但是这无法用第一个文本的空格连字符空格模式替换单个空格中的字符串.因此,当我尝试使用此文本时,例如:

Code Geass - Lelouch of the Rebellion
Run Code Online (Sandbox Code Playgroud)

它只是将其返回到字符串名称:

Code Geass - Lelouch of the Rebellion
Run Code Online (Sandbox Code Playgroud)

但它应该实际上返回这个:

Code Geass Lelouch of the Rebellion
Run Code Online (Sandbox Code Playgroud)

我的想法怎么了?或者我可以采用不同的方式吗?我在这里先向您的帮助表示感谢.

请求的完整代码:http: //pastebin.com/hwUtFe8N

abe*_*nky 5

在代码中,我只看到.Replace(" ", "-");
(如更换spacedash)

我没有看到你所描述的内容,而只是用a代替space-dash-spacespace.

换句话说,您的代码与您的问题不符.