title: login/register form using arrays
body: <p>I'm having problems in passing the values of the array. </p>
  
  <p>I created an array in a class, then I instantiate it in <code>frmMain(form1)</code> then i put some values in the array(I signed up I put username and password in the array). <code>frmMain</code> should pass the values in the the array right? </p>
  
  <p>My problem is when I instantiate the class(which holds the array) in <code>frmProfile(form2)</code> its like i never put some values in it. </p>
  
  <p>In short, I want the array to be accessible in all forms. Do I need a constructor method?(something like get; set;?).</p>
  
  <pre><code>public class Tagasalo //this is the class i created
  {
      public String[,] array = new String[5, 2];
  
  }
  </code></pre>
  
  <p>heres my code in frmMain(form1)</p>
  
  <pre><code>    Tagasalo arr = new Tagasalo();
      frmProfile profile = new frmProfile();
  
      int row;
      bool validInput = true;
      int tries = 3;
  
  
      public frmMain()
      {
          InitializeComponent();
  
      }
  
      public void btnSignUp_Click(object sender, EventArgs e)
      {
          if (txtUsernameS.Text.Trim() == String.Empty)
          {
              errorProvider1.SetError(txtUsernameS, "Please put a Username.");
          }
          else if (txtUsernameS.TextLength &gt; 1 &amp;&amp; txtUsernameS.TextLength &lt; 4)
          {
              errorProvider1.SetError(txtUsernameS, "Your Username must have 4 or more characters.");
          }
          else
          {
              errorProvider1.Clear();
          }
  
          if (txtPasswordS.Text == String.Empty)
          {
              errorProvider2.SetError(txtPasswordS, "Please put a Password.");
          }
          else if (txtPasswordS.TextLength &gt; 1 &amp;&amp; txtPasswordS.TextLength &lt; 6)
          {
              errorProvider2.SetError(txtPasswordS, "Your Password must have 6 or more characters.");
          }
          else
          {
              errorProvider2.Clear();
          }
  
          for (row = 0; row &lt; 5; row++)
          {
              if (txtUsernameS.TextLength &gt;= 4 &amp;&amp; txtPasswordS.TextLength &gt;= 6)
              {
                  if (txtConfirmPassword.Text != txtPasswordS.Text)
                  {
                      errorProvider3.SetError(txtConfirmPassword, "Your Password does not match.");
                  }
                  else if (txtConfirmPassword.Text == txtPasswordS.Text)
                  {
                      if (arr.array[row, 0] == null &amp;&amp; arr.array[row, 1] == null)
                      {
                          arr.array[row, 0] = txtUsernameS.Text;
                          arr.array[row, 1] = txtPasswordS.Text;
                          MessageBox.Show("Signed-Up Successfully!");
  
                          break;
                      }
                      else if(txtUsernameS.Text == arr.array[row,0])
                      {
                          MessageBox.Show("Username already Used.");
                          break;
                      }
                  }
              }
          }
          if (row &gt; 5)
          {
              MessageBox.Show("Sorry, maximum number of accounts has been reached.");
          }
      }
  </code></pre>
  
  <p>here's my code in frmProfile(form2)- In this form I just want the label to show the username of the user.</p>
  
  <pre><code>    Tagasalo arr = new Tagasalo();
      int row;
  
      public frmProfile()
      {
          InitializeComponent();
  
      }
  
      private void changePasswordToolStripMenuItem_Click(object sender, EventArgs e)
      {
          frmChangePassword changepass = new frmChangePassword();
          changepass.Show();
          this.Hide();
      }
  
      private void logOutToolStripMenuItem_Click(object sender, EventArgs e)
      {
          frmMain logout = new frmMain();
          logout.Show();
          this.Hide();
      }
  
      public void frmProfile_Load(object sender, EventArgs e)
      {
          for (row = 0; row &lt; 5; row++ )
          {
              if(arr.array[row,0] == arr.array[row,1])
              {
                  lblUsername.Text = arr.array[row, 0];
                  break;
              }
          }
      }
  </code></pre>
  
  <p>then, i want to change the password. replace the value of the array and when i log-out the array is empty again. I cant log-in again with the same account.</p>
  
  <pre><code>    Tagasalo arr = new Tagasalo();
  
      public frmChangePassword()
      {
          InitializeComponent();
      }
  
      private void btnSaveChanges_Click(object sender, EventArgs e)
      {
          if (txtCurrentPassword.Text == String.Empty)
          {
              errorProvider1.SetError(txtCurrentPassword, "Please type your Current Password.");
          }
          else
          {
              errorProvider1.Clear();
          }
  
  
          if (txtNewPassword.Text == String.Empty)
          {
              errorProvider2.SetError(txtNewPassword, "Please type your New Password.");
          }
          else
          {
              errorProvider2.Clear();
          }
          if (txtConfirmNewPassword.Text != txtNewPassword.Text)
          {
              errorProvider3.SetError(txtConfirmNewPassword, "Re-type your New Password.");
          }
          else
          {
              errorProvider3.Clear();
          }
  
          if(txtCurrentPassword.Text != String.Empty &amp;&amp; txtNewPassword.Text != String.Empty &amp;&amp; txtConfirmNewPassword.Text == txtNewPassword.Text)
          {
  
              MessageBox.Show("Changed Password Successfully!");
              frmProfile profile = new frmProfile();
  
              profile.Show();
              this.Hide();
          }
      }
  
      private void btnCancel_Click(object sender, EventArgs e)
      {
          frmProfile profile = new frmProfile();
          profile.Show();
          this.Hide();
      }
  </code></pre>
  
  <p>Sorry if it's too long. I've been searching the net for days after school and I cant find the answer. </p>