title: C# Client/Server: using Streamreader/writer
body: <p>I'm relatively new to C# but here goes: </p>
  
  <p>I am developing a remote file service client/server console application in C# which is supposed to exchange messages using synchronous sockets. </p>
  
  <p>One of the main problems (even thought it might seem simple) is to return a string from the server, to the client using streamreader/streamwriter.</p>
  
  <p>The application user a command line interface with options (from a switch statement) to execute actions. I.e. typing 1 and enter would execute the code to send the string from the server to the client.</p>
  
  <p>Below is a sample code from the client:</p>
  
  <pre><code>        try
          {
              using (TcpClient client = (TcpClient)clientObject)
              using (NetworkStream stream = client.GetStream())
              using (StreamReader rd = new StreamReader(stream))
              using (StreamWriter wr = new StreamWriter(stream))
              {
  
                  string menuOption = rd.ReadLine();
  
  
                  switch (menuOption)
                      {
                          case "1":
                          case "one":
                              string passToClient = "Test Message!";
                              wr.WriteLine(passToClient);
                              break;
                     } 
                        while (menuOption != "4");
                 }
           }
  </code></pre>
  
  <p>I understand the code I posted is just a snippet of the program, but it would take up a fair amount of space and was hoping you can gather what I mean from this, if not I will post more.</p>
  
  <p>This is just to give a general idea of what I am going for, </p>
  
  <p>I appreciate any help / advice you can give. Its not so much code examples I'm looking for (although a little would help) but more some explanation on streamreader/writer as I cant seem to understand much of what is online.</p>
  
  <p>Thanks.</p>