Invoked member

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Mecena
    New Member
    • Apr 2007
    • 31

    Invoked member

    Hi all!

    I'm trying to create a method in c# that would spoof the parameters of the method that called it... is there a way to do it? how can i get the invoked member?
  • namit101
    New Member
    • Feb 2008
    • 7

    #2
    I'm not exactly sure what you mean. Perhaps you mean, how do you pass the reference of an argument to the method? For example:

    Code:
    
    ///this function would return 12;
    public int add()
    {
    int a1 = 1;
    int a2 = 2;
    
    Change(out a1,out a2);
    
    return a1+a2;
    
    }
    
    public void Change(out int a,out int b)
    {
     a = 5;
    b=7;
    }
    If that's what you're looking for, please search google for how to use the "ref" and "out" keywords. If not, please clarify.

    Hope I've helped.

    Comment

    • Mecena
      New Member
      • Apr 2007
      • 31

      #3
      that's not what i meant...
      what i need is a way to get the real arguments of the method that called another method in runtime.
      ex. if i have something like this:

      [CODE]
      public static void CallerFunc(int a, int b, string c)
      {
      SpoofParams();
      }
      [CODE]

      i want the SpoofParams() func. to reflect the params passed to CallerFunc, not the metadata that you get reflecting the type, but the actual variables.
      It should work generally anywhere, so i can't use reflection to get the method
      signature by name....



      Originally posted by namit101
      I'm not exactly sure what you mean. Perhaps you mean, how do you pass the reference of an argument to the method? For example:

      Code:
      
      ///this function would return 12;
      public int add()
      {
      int a1 = 1;
      int a2 = 2;
      
      Change(out a1,out a2);
      
      return a1+a2;
      
      }
      
      public void Change(out int a,out int b)
      {
       a = 5;
      b=7;
      }
      If that's what you're looking for, please search google for how to use the "ref" and "out" keywords. If not, please clarify.

      Hope I've helped.

      Comment

      Working...