title: dictionary and string split in server
body: <p>Hi I am having problem with my dictionary initialization. I have to declare a dictionary and populated with the (userName) and (location) which I am reciving from the client. when it finds the userName it should send back the location if not it shouls send back"no entries found" and if the location is it updated then it should say "OK". Right now i am getting an out of bounds error can someone help me fix it. thank you.</p>
  
  <pre><code>protected static Dictionary&lt;string, string&gt; dict = new Dictionary&lt;string, string&gt;();
  
  static void doRequest(NetworkStream socketStream)
  {
      try
      {
          StreamWriter sw = new StreamWriter(socketStream);
          StreamReader sr = new StreamReader(socketStream);
  
          String line = sr.ReadLine();   
          Console.WriteLine("Respond recived " + line);
  
          String[] sections = line.Split(new char[] { ' ' }, 2);
  
          dict.TryGetValue(sections[0],out sections[1]);
  
          if(sections[0].Length&gt;1)
          {
              sw.WriteLine(sections[1]);
              sw.Flush();
          }
          else
          {
              sw.WriteLine("no entries found");
              sw.Flush();
          }
          if(sections[1].Length&gt;2)
          {
              sw.WriteLine("OK");
              sw.Flush();
          }
  
      catch (Exception e)
      {
          Console.WriteLine(e);
  
      }
  
  }
  </code></pre>