title: Global instances of class
body: <p>Still trying to get to know C# (Mostly worked with C). I have a class "Device" and would like to create an instance of the class, but would also like access to the instances globally because I use them so much in my GUI methods. </p>
  
  <pre><code> public class Device
      {
          public string Name;
          public List&lt;string&gt; models = new List&lt;string&gt;();
          public List&lt;string&gt; revisions = new List&lt;string&gt;();
          ...
      }
  </code></pre>
  
  <p>Somehow declare this globally:</p>
  
  <pre><code> Device Device1 = new Device();
   Device1.Name = "Device1";
  </code></pre>
  
  <p>Then access it later in a WPF method:</p>
  
  <pre><code> private void DeviceViewItem_Selected(object sender, RoutedEventArgs e)
      {
         TreeViewItem selected = (TreeViewItem)sender;
  
          if (selected.Name == Device1.Name)
          {
              Device1.Models.Add("something");
              Device1.Revisions.Add("something");
          }
  </code></pre>
  
  <p>I've been reading about singleton Pattern, but it looks like you have to create a Singleton Class, but my "Device" Class is used multiple times to create many devices. Maybe I just don't understand the pattern that well.</p>