none
Anyone knows how to do it? RRS feed

  • Question

  • I have a class called "Class1":

        public class Class1
        {
           Class2 Class2 = new Class2();
    
           public Class1(){
           AnotherAction();
    
          }
           public AnotherAction(){
           Class2.Action();
           }
    
            public void Action(){
    
            }
    
        }
    
       public class Class2
       {
    
        public void Action(){
      //HERE I NEED TO CALL THE CLASS1 ACTION - FATHER OBJECT (THE OBJECT THAT CALLED THE CLASS2)
         Class1.Action();
        }
       }
    Anyone knows how to do it?
    Friday, January 8, 2010 12:52 AM

Answers

  •  public class Class1
        {
           Class2 Class2 = new Class2(this);

           public Class1(){
           AnotherAction();

          }
           public AnotherAction(){
           Class2.Action();
           }

            public void Action(){

            }

        }

       public class Class2
       {
         Class1 _Parent;
         public Class2(Class1 Parent)
         {
             _Parent = Parent;
         }
        public void Action(){
          _Parent.Action();
        }
       }
    • Marked as answer by anon012010 Friday, January 8, 2010 1:45 AM
    Friday, January 8, 2010 1:15 AM

All replies

  •  public class Class1
        {
           Class2 Class2 = new Class2(this);

           public Class1(){
           AnotherAction();

          }
           public AnotherAction(){
           Class2.Action();
           }

            public void Action(){

            }

        }

       public class Class2
       {
         Class1 _Parent;
         public Class2(Class1 Parent)
         {
             _Parent = Parent;
         }
        public void Action(){
          _Parent.Action();
        }
       }
    • Marked as answer by anon012010 Friday, January 8, 2010 1:45 AM
    Friday, January 8, 2010 1:15 AM
  • Thanks
    Friday, January 8, 2010 1:45 AM