Comparing string arrays My code does what I need it to do, but I think I am missing the "right" way to do this with comparing the arrays. Essentially what I need this to do is compare a textbox entry against two different arrays and redirect based on which value matches. 

Protected void Button1_Click(object sender, EventArgs e)
{              
      string[] str1 = new string[] {"87002", "87001", "87005"};
      string[] str2 = new string[] {"97002", "97003", "97004"};

      for (int i = 0; i &lt; str1.Length; i++)
      {
          string comp1 = str1[i];
          if (comp1 == TextBox1.Text.ToString())
          {
              Response.Redirect("Page1.aspx");
          }
      }

      for (int i = 0; i &lt; str2.Length; i++)
      {
          string comp2 = str2[i];
          if (comp2 == TextBox1.Text.ToString())
          {
              Response.Redirect("Page2.aspx");
          }
      }          
      Response.Redirect("Unknown.aspx");
}
I would do this:

protected void Button1_Click(object sender, EventArgs e)
{              
    string[] str1 = new string[] {"87002", "87001", "87005"};
    string[] str2 = new string[] {"97002", "97003", "97004"};

    if (str1.Contains(TextBox1.Text))
        Response.Redirect("Page1.aspx");

    if (str2.Contains(TextBox1.Text))
        Response.Redirect("Page2.aspx");

    Response.Redirect("Unknown.aspx");
}


You don't need the ToString() calls - TextBox.Text should already be a string.