Written code does not work.
I try to solve in LINQPad:
void Main() { Debug.Assert(Foo("Is this a problem?") == "Is this a problem?", "Test # 1"); Debug.Assert(Foo(" Is this a problem?") == "Is this a problem?", "Test # 2"); Debug.Assert(Foo(" Is this a problem? ") == "Is this a problem?", "Test # 4"); Debug.Assert(Foo(" Is this a problem? ") == "Is this a problem?", "Test # 5"); Debug.Assert(Foo(" Is this a problem? ") == "Is this a problem?", "Test # 6"); } string Foo(string s) { s = s.Replace(" ",""); return s; }