title: C# Index and length must refer to a location within the string. Parameter name: length
body: <p>I want to add this code but it doesn't work. It is from a chat system, when a player connects to server I want in his textbox (chat) to show <code>HelloMsg</code> but when I start the program I get an error.</p>
  
  <p>Sorry for my bad english!</p>
  
  <pre><code>#region ' Read Configuration.ini '
  StreamReader Sr = new StreamReader(Database + "\\Configuration.ini");
  
  string line = null;
  
  while ((line = Sr.ReadLine()) != null)
  {
      if (line.Substring(0, 12) == "HelloMessage")
      {
          string[] StrMsg = line.Split('=');
          HelloMsg = StrMsg[1].Trim();
      }
  }
  
  Sr.Close();
  </code></pre>