title: Switch case taking array item instead of strict values
body: <p>I was wondering if someone could explain to me why it is that you can not use <code>array[index]</code> in a switch case.</p>
  
  <p>I stumbled upon this while making a simple settings read/write class and it had me a bit confused for a while as the debugger told me that all values was correct.</p>
  
  <p>Example one, this code does not work:</p>
  
  <pre><code>String[] lines = File.ReadAllLines(filePath);
  foreach(String line in lines) {
      String[] args = line.Split(':');
      switch(args[0]) {
          case "Version":
              Version = args[1].Trim();
              break;
          case "Run Local":
              RunLocal = (args[1].Trim().ToLower() == "true") ? true : false;
              break;
      }
  }
  </code></pre>
  
  <p>Example two, please note that I use a <code>String val = args[0]</code> before the switch</p>
  
  <pre><code>String[] lines = File.ReadAllLines(filePath);
  foreach(String line in lines) {
      String[] args = line.Split(':');
      String val = args[0];
      switch(val) {
          case "Version":
              Version = args[1].Trim();
              break;
          case "Run Local":
              RunLocal = (args[1].Trim().ToLower() == "true") ? true : false;
              break;
      }
  }
  </code></pre>
  
  <p><strong>EDIT</strong></p>
  
  <p>There seem to be a bit of confusion, so I've updated the code examples to show the entire method and I will try to elaborate a bit.</p>
  
  <p>When using args[0] in my switch, it does not match the value with any of the cases despite actually being identical (I refer to the attached image of the inspector). The code basically just carries on as if no match was found.</p>
  
  <p>I have settigns.txt where I simply read all files with <code>File.ReadAllLines(filePath)</code>. This settings file look like this:</p>
  
  <pre><code>Version: 0
  Run Local: true
  </code></pre>
  
  <p>Images of the inspector:</p>
  
  <p><a href="https://i.stack.imgur.com/UMhn1.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/UMhn1.png" alt="enter image description here"></a></p>