title: Verifying that a multidimensional array contains a pair of values
body: <p>I am making a signin form for a webpage. I have created a multidimensional array with acceptable username/password combinations. I would like to allow the user to move on to the next page only if their username/password combination is found in the array. If they enter a combination that is not found in the array, I want an error to raise and keep them from proceeding to the next page.</p>
  
  <p>I understand that this is not the most effective way to complete this command, but I am learning how to properly use Arrays as part of the foundation to my programming knowledge. I'll paste my code below. I've tried various way to get the page to do what I want, but I can't seem to get it. I get this error: "System.IndexOutOfRangeException: Index was outside the bounds of the array." Here is my code:</p>
  
  <pre><code>&lt;%@ Page Language="C#" %&gt;
  
  &lt;!DOCTYPE html&gt;
  
  &lt;script runat="server"&gt;
      string[,] UserPass = new string[,] {{"user1","pwd1"}, {"user2", "pwd2"}, {"user3","pwd3"}};
  
  
  void Page_Load(object sender, EventArgs e)
      {        
  
      }
  
      void btnSignin_Click(object sender, EventArgs e)
      {
           if(txtSignin.Text == UserPass[1,0] &amp;&amp; txtPWD.Text == UserPass[0,1])
           {
               Response.Redirect("welcome.aspx");
           }
  
           else if (txtSignin.Text == UserPass[2, 0] &amp;&amp; txtPWD.Text == UserPass[0, 2])
           {
               Response.Redirect("welcome.aspx");
           }
  
           else if (txtSignin.Text == UserPass[3, 0] &amp;&amp; txtPWD.Text == UserPass[0, 3])
           {
               Response.Redirect("welcome.aspx");
           }
  
           else 
           {
               Response.Write("Please try again."); 
           }
      }
  &lt;/script&gt;
  
  &lt;html xmlns="http://www.w3.org/1999/xhtml"&gt;
  &lt;head runat="server"&gt;
      &lt;title&gt;&lt;/title&gt;
      &lt;link rel="stylesheet" type="text/css" href="stylesheet.css" /&gt;
  &lt;/head&gt;
  &lt;body&gt;
      &lt;form id="form1" runat="server"&gt;
      &lt;div&gt;
      &lt;p&gt;Sign in with Account&lt;/p&gt;
          &lt;asp:Panel ID="Pnl1" runat="server"&gt;
              &lt;br /&gt;
              &lt;asp:Textbox ID="txtSignin" runat="server" Text="Username" style="width:190px" /&gt;&lt;br /&gt;
              &lt;asp:TextBox ID="txtPWD" runat="server" Text="Password" TextMode="Password" style="width:190px" /&gt;&lt;br /&gt;
              &lt;asp:LinkButton ID="btnSignin" runat="server" Text="Sign in" class="myBtn" OnClick="btnSignin_Click"/&gt;&lt;br /&gt;
              &lt;asp:CheckBox ID="chkRemember" runat="server" Text="Stay signed in" /&gt;
          &lt;/asp:Panel&gt;
          &lt;asp:Label ID="lblSignin" runat="server" /&gt;
      &lt;/div&gt;
      &lt;/form&gt;
  &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>
  
  <p>(also, on a smaller note, is it possible to have the signin/password boxes display text that disappears when the users clicks the textbox?)</p>
  
  <p>Thank you for any help!</p>