title: C# Receive Data from Socket and put it in a String?
body: <p>I have a socket server and am trying to receive a string from the client. </p>
  
  <p>The client is perfect and when I use this </p>
  
  <pre><code>Socket s = myList.AcceptSocket();
  Console.WriteLine("Connection accepted from " + s.RemoteEndPoint);
  
  byte[] b = new byte[100];
  int k = s.Receive(b);
  Console.WriteLine(k);
  Console.WriteLine("Recieved...");
  for (int i = 0; i &lt; k; i++) {
      Console.Write(Convert.ToChar(b[i]));
      ASCIIEncoding asen = new ASCIIEncoding();
      s.Send(asen.GetBytes("The string was recieved by the server."));
  }
  </code></pre>
  
  <p>All is okay and I get my string in the console. </p>
  
  <p>But how can I get now my receive into a string so I can use it in a switch case? </p>
  
  <p>Like this:</p>
  
  <pre><code>string action = Convert.ToChar(b[i]);
  </code></pre>
  
  <p>Error:</p>
  
  <blockquote>
    <p>The Name i isn't in the current context. 
    its the only Error Message i get. </p>
  </blockquote>