title: c# using program.cs to refer to form2 in form1 has error
body: <pre><code>using System;
  using System.Collections.Generic;
  using System.Linq;
  using System.Windows.Forms;
  
  namespace Test
  {
      static class Program
      {
          /// &lt;summary&gt;
          /// The main entry point for the application.
          /// &lt;/summary&gt;
          public static Form1 f;
          public static Form2 f2;
          [STAThread]
          static void Main()
          {
              Application.EnableVisualStyles();
              Application.SetCompatibleTextRenderingDefault(false);
              Application.Run(new Form1());
              f = new Form1();
              f2 = new Form2();
          }
      }
  }
  private void button1_Click(object sender, EventArgs e)
  {
   Program.f2.Show();
  </code></pre>
  
  <p>this.Hide();
      }</p>
  
  <p>The button gives "Object reference not set to an instance of an object." error. How do I fix this? I don't see any error in my code.</p>