calling functions one after another and get result into Main again

Dear all,

I have this C# code.

public class SimpleUdpClient{
...
void recieve_msg(){...
msg[] contains data...
}


void capture_off(){...
recieve_msg();...
}

public unsafe static void Main(string[] args){...
simpleclient.capture_off();
fixed (byte* pSrc = msg, pDst = buffer)
{...I want to use the data in msg[] to save to buffer[] here and do other operations...
}
}
}

But how do I get the data after Main calls capture_off(), then capture_off calls recieve_msg() and get the msg[] from there to continue working in Main. Hope you guys are not confused by me. Really appreciate your help!

Thanks a million.

Regards,
Siew eng



Answer this question

calling functions one after another and get result into Main again

  • Tech_Prince

    Can't you make a common variable to store the return result and pass it to the main

    public class SimpleUdpClient{ 
    msg[] returnMsg;
    ...
    void recieve_msg(){...
    msg[] contains data...
    returnMsg = data;
    }


    void capture_off(){...
    recieve_msg();...
    }

    public unsafe static void Main(string[] args){...
    simpleclient.capture_off();
    fixed (byte* pSrc = msg, pDst = buffer)
    {...using returnMsg to continue your operations...
    }
    }
    }



  • Rockbooster

    Dear Jacky,

    I donno if this is what you meant but i placed a static keyword in front of msg[] declaration and it seems to work in my program.

    Thank you very much.

    Sieweng
    Big Smile


  • calling functions one after another and get result into Main again