title: C# winform: Accessing public properties from other forms & difference between static and public properties
body: <p>I am trying to understand whats the difference between a static and public properties. But when I tried to access my public property 'Test' in other form it says 'null'.</p>
  
  <p>Heres Form1:</p>
  
  <pre><code>public partial class Form1 : Form
  {
      public Form1()
      {
          InitializeComponent();
      }
  
      private string _test;
  
      public string Test
      {
          get { return _test; }
          set { _test = value; }
      }
  
      private void Form1_Load(object sender, EventArgs e)
      {
          _test = "This is a test";
      }
  
      private void button1_Click(object sender, EventArgs e)
      {
          Form2 frm2 = new Form2();
          frm2.Show();
      }
  }
  </code></pre>
  
  <p>Here's Form2:</p>
  
  <pre><code>public partial class Form2 : Form
  {
      public Form2()
      {
          InitializeComponent();
      }
  
      private void Form2_Load(object sender, EventArgs e)
      {
          Form1 frm1 = new Form1();
          label1.Text = frm1.Test;
      }
  }
  </code></pre>
  
  <p>To check the value of 'Test' in Form1, I put a breakpoint to this line:</p>
  
  <pre><code>label1.Text = frm1.Test;
  </code></pre>
  
  <p>But the value is 'null'. </p>
  
  <p>Please help me how can I access public properties to other forms. </p>
  
  <p>And BTW I tried to make this public property be a 'public static'. I can access this using this: </p>
  
  <pre><code>Form1.Test
  </code></pre>
  
  <p>But I noticed that I can change 'Test' value from Form2 which I don't want to happen. That's why I am trying to use public property but with no luck. Can somebody clarify me these things. Thanks for all your help guys! </p>
  
  <pre><code>EDIT: (For follow up question) 
  </code></pre>
  
  <p>Sir John Koerner's answer is the best answer for my question. But I have a follow up question, I tried to make these 'test' properties to be a 'static', and I noticed that even if I make this property a static or public property, it still can be edit in Form2. To make myself clear here's a sample: </p>
  
  <pre><code>public partial class Form2 : Form
  {
      private Form1 f1;
      public Form2(Form1 ParentForm)
      {
          InitializeComponent();
          f1 = ParentForm;
      }
  
      private void Form2_Load(object sender, EventArgs e)
      {
          label1.Text = f1.Test;
      }
  
      private void button1_Click(object sender, EventArgs e)
      {
          f1.Test = "This test has been changed!";
  
          this.Close();
      }
  }
  </code></pre>
  
  <p>After Form2 closed, I tried to break again in Form1_Load to check value of 'Test', and it was changed! How can I make a public property in Form1 to readOnly in Form2 and cannot be editted? Please clarify to me. Thanks a lot guys!</p>