title: C# After string is sent via Networkstream, it can be read but doesn't work with "if"
body: <p>I've written a little socket application in C# that checks for the current version of my program at every start, now in my test program for this everything works, i can send the string from the server  and it will be properly shown on the client, but when I try to use an if statement with that string it just does not work. Example:</p>
  
  <pre><code>    public void rcv(NetworkStream ns, TcpClient clientSocket)
      {
          on = false;
      //sending some random string so the server will respond
         Byte[] sendBytes = Encoding.ASCII.GetBytes("bla");
          ns.Write(sendBytes, 0, sendBytes.Length);
      //receiving server response 
          byte[] bytes = new byte[clientSocket.ReceiveBufferSize];
          int bytesread = clientSocket.ReceiveBufferSize;
          ns.Read(bytes, 0, bytesread);
      //received response, now encoding it to a string from a byte array
          string returndata =Encoding.ASCII.GetString(bytes);
          ver = Convert.ToString(returndata);
          //MessageBox.Show("ver\n" + ver);
          //MessageBox.Show("return\n" + returndata);
          on = true;
          if (ver== "2.0.1")
          {
              MessageBox.Show("iahsd");
          }
      }
  </code></pre>
  
  <p>So as you can see, the test string im using that is being sent by the server is "2.0.1" does does display properly on a label, a message box and a textbox that i put in for testing. but the if branch at the end of the class does not accept it and skips over it, if i put an else statement in, it skips to that.</p>
  
  <p>i have tried everything me and my friends could think of, tried changing the encoding, sent different strings, etc ..</p>
  
  <p>full code of the client :
  <a href="http://pastebin.com/bQPghvAH" rel="nofollow">http://pastebin.com/bQPghvAH</a></p>