Using foreach statement
<p>I was trying to see if I could use the foreach statement to try and get the program I made to search through an entire array since I don't have a preset size for it and I don't want to play a guessing game for it. I tried this block of code but it tells me, "cannot implicitly convert type 'string' to 'int' and it points to the line 'if (query == search[k])</p>

<p>I'm not sure exactly what it is talking about but can someone please assist? Thank you.</p>

<pre><code>    private void findLast_Click(object sender, EventArgs e)
    {
        query = textBox2.Text;
        search = File.ReadAllText(fileName).Split(new string[] { "\n", "\r\n", ":" }, StringSplitOptions.RemoveEmptyEntries);
        foreach (string k in search)
        {
            if (query == search[k])
            {
                MessageBox.Show("Match");
            }
            else
                MessageBox.Show("No Match");
        }
    }
</code></pre>
