title: C# assign textbox value to a variable in another class in another file
body: <p>I have created a simple form <strong>"people"</strong> and there is another file <strong>"Information.cs"</strong> </p>
  
  <p>In main for assign text box "txt_lname" value to a variable</p>
  
  <pre><code>String lastname = txt_lname.Text;
  </code></pre>
  
  <p>Then I want to use this value within  <strong>"information class"</strong> <em>(It is a thread class)</em></p>
  
  <p>How can I use it ? </p>
  
  <p><strong><em></strong>(I have commented the place I wanted to use that value)<strong></em></strong></p>
  
  <p><strong>Main Form</strong></p>
  
  <pre><code>namespace users
  {
      public partial class people : Form
      {
          public people()
          {
              InitializeComponent();   
          }
  
          private void btn_login_Click(object sender, EventArgs e)
          {
              String lastname = txt_lname.Text;
          }
      }
  }
  </code></pre>
  
  <p><strong>Information Class</strong></p>
  
  <pre><code>namespace users
  { 
      class Information
      {             
          int[] idno = new int[10];
          int[] age = new int[10];
          string[] fname = new string[10];
  
          // Here I want to assign txt_lname.Text value to a variable
          lastname = txt_lname.Text; // This code is not working 
  
          public void run()
          {
              while (true)
              {
  
                  for (int i = 0; i &lt; 600; i++)
                  {
                      //Some code here
  
                      try
                      {
                          Thread.Sleep(100);
                      }
                      catch (Exception ex)
                      {
                          MessageBox.Show(ex.ToString(), "Error", MessageBoxButtons.OKCancel, MessageBoxIcon.Error);
                      }
  
                  }
              }
          }
      }
  }
  </code></pre>
  
  <p><strong>* Can I use value of a variable within run method in thread class ? if cannot then why ?</strong>  </p>