title: Working with multiple forms using c# in Visual Studio
body: <p>I'm currently developing a Windows Form Application that uses two forms. I have no problems linking between the two forms. My issue is accessing a variable in Form2 that was created in Form1. How do you make a variable accessible to multiple forms in the same project?. I honestly tried to look for an answer, but could not find anything. Any help would be appreciated. </p>
  
  <p>Here is the code for Form1:</p>
  
  <pre><code>  namespace HourlyAlarm1
    {
      public partial class AlarmToneSetter : Form
       {
         public bool halfHourSelected;
  
         public AlarmToneSetter()
         { 
            InitializeComponent();
         }
  
         private void okButton_Click(object sender, EventArgs e)
         {
            if(halfHourRadio.Checked)
            {
              halfHourSelected = true;
            }
            else
            {
              halfHourSelected = false;
            }
  
            Form1 f1 = new Form1();
            f1.ShowDialog();
        }
  
        public bool getHalfHourSelect()
        {
           return halfHourSelected;
        }
     }
   }
  </code></pre>
  
  <p>Here is the code for Form2:</p>
  
  <pre><code>    namespace HourlyAlarm1
      {
        public partial class Form1 : Form
        {
          int min;
          System.Media.SoundPlayer sp;
  
          public Form1()
         {
            InitializeComponent();
         }
  
         private void playSound()
         {
           sp = new      System.Media.SoundPlayer(HourlyAlarm1.Properties.Resources.chipfork);
           sp.Load();
           sp.Play();
         }
  
         private void timer1_Tick(object sender, EventArgs e)
         {
            TimeLabel.Text = DateTime.Now.ToLongTimeString();
            min = DateTime.Now.Minute;
  
            if(HourlyAlarm1.AlarmToneSetter.g)
            if(min == 0)
            {
              playSound();
            }
  
        }
    }
  </code></pre>
  
  <p>}</p>