title: C# Error: Unassigned local variable error when using "switch"?
body: <p>What I want to achieve is, to show count of lines ending with/starting with (user selects type by comboBox1) given character (by textbox1).</p>
  
  <p>Trying to compile this code:</p>
  
  <pre><code>string needle=textBox1.Text.Trim(), cboxSelection = comboBox1.Text;
  int count;
  switch (cboxSelection)
  {
      case "Starting with":
          count = File.ReadLines(openFileDialog1.FileName).Count(line =&gt; Regex.IsMatch(line, "^" + needle + ".*$"));
          break;
      case "Ending with":
          count = File.ReadLines(openFileDialog1.FileName).Count(line =&gt; Regex.IsMatch(line, "^.*" + needle + ".*$"));                    
          break;
  }
  string strCount = count.ToString(); // error line
  label6.Text = "There are " + strCount + " lines " + cboxSelection + " " + needle + " character.";
  </code></pre>
  
  <p>Getting error message: <code>Use of unassigned local variable 'count'</code>. What am I missing?</p>