i was working on a personal program, and in it, i get some strings which may have a space hyphen space. or something like this: ” – “ and what I have to do is replace this with a single space. Now, the problem is, when i try to use a replace method from the c# library it doesn’t seem to do anything.
This is what i tried:
string firsttext = firsttextbox.Text.ToLower();
string name = firsttext.Replace(" - ", " ");
But this fails to replace the string in firsttext’s space hyphen space pattern with a single space. So when i try to use this text for example:
Code Geass - Lelouch of the Rebellion
it just returns this into string name:
Code Geass - Lelouch of the Rebellion
however it should actually be returning this:
Code Geass Lelouch of the Rebellion
Whats wrong with my idea? Or can I do it differently? Thanks for the help in advance.
Full code for those requested:
http://pastebin.com/hwUtFe8N
In your code, I only see
.Replace(" ", "-");(eg. Replace
spacewithdash)I don’t see what you describe, which is replacing a
space-dash-spacewith just aspace.In otherwords, your code doesn’t match your question.