title: static class variable scope issue in C# winforms - why doesn't this bit of code work?
body: <p>I've got two different forms in my WinForms app (MainForm and Form2 say).  They both ask for an access of MyDataSet, via a "getInstance" static method.  The issue is after MainForm has got an instance, when Form2 needs to get an instance the static "myDataSet" variable is null, whereas I expect to have been already set?  Any ideas?</p>
  
  <pre><code>public class MyDataSet
  {
      public static MyDataSet myDataSet;   
         // This was null 2nd call to getInstance
  
      private DataSet myData = new DataSet();
  
      public static MyDataSet GetInstance()
      {
          if (myDataSet == null)
          {
              return new MyDataSet();
          }
          else
          {
              return myDataSet;
          }
      }
  </code></pre>
  
  <p>So it almost seems the static "myDataSet" variable isn't working in terms of only having once instance?</p>