Global Variable Problem

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I am writing a piece of software which loads multiple parts into different
panels. Each panel can access other panels by accessor methods. My team
wants to create a global variable of type Queue from the System.Collection
class. We want to be able to access this variable in other panels via a call
similar to the following:

Queue localQueue = MainClass.myQueue;

This is similar to the old inline functions in C++ used by the Math
libraries to call functions like Math.Pi. Is there a way to do this in C#
2003 or do I need to develop a wrapper class for the Queue with a custom add
and remove functions.
 
You are simply looking for a static member. Static members can easily be shared
by name amongst all of your panels. If you need something more instance based,
perhaps you have multiple forms and panels in each form that need access to the
Form's queue, then you can always get the top level parent, cast to your form
type, and access public properties.
 
Back
Top