CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 15 of 23

Threaded View

  1. #1
    Join Date
    Apr 2009
    Posts
    18

    static variables

    hi everyone ,
    Im having problems in saving values in the static variables. Here it is how it goes
    i have 3 projects in a solution. Lets say A , B and C.
    I have added the references of C in A and B
    A calls C and saves a value .
    Later B calls C but B get the value as 0(even though this variable wasnt used anywhere in between)
    this is how my code looks like


    A:
    Code:
    public   class Program 
        {
     static void Main(string[] args)
            {
    ...
    ...
     Mediator.Class1 mediat = new Mediator.Class1();
      mediat.test(4);
      waitHandle.WaitOne();
             }
       }

    B:
    Code:
    ...
    ...
    
     Mediator.Class1 mediat = new Mediator.Class1();
               mediat.recieveEle(request);
    C:
    Code:
     public   class Class1
        {
     public static int m_globalVar = 0;
    int j;
    
         public static int GlobalVar
            {
                get { return m_globalVar; }
                set { m_globalVar = value; }
            }
     public void test( int i)
            {
             
                GlobalVar = i;
            }
            public void recieveEle(Element ele)
            {
                j = GlobalVar;
    
            }
        }
    Last edited by nightscorpion; May 12th, 2009 at 03:10 AM.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured