473,387 Members | 3,684 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

Invoked member

31
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?
Mar 12 '08 #1
2 986
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:

Expand|Select|Wrap|Line Numbers
  1.  
  2.  
  3. ///this function would return 12;
  4. public int add()
  5. {
  6. int a1 = 1;
  7. int a2 = 2;
  8.  
  9. Change(out a1,out a2);
  10.  
  11. return a1+a2;
  12.  
  13. }
  14.  
  15. public void Change(out int a,out int b)
  16. {
  17.  a = 5;
  18. b=7;
  19. }
  20.  
  21.  
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.
Mar 12 '08 #2
Mecena
31
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....



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:

Expand|Select|Wrap|Line Numbers
  1.  
  2.  
  3. ///this function would return 12;
  4. public int add()
  5. {
  6. int a1 = 1;
  7. int a2 = 2;
  8.  
  9. Change(out a1,out a2);
  10.  
  11. return a1+a2;
  12.  
  13. }
  14.  
  15. public void Change(out int a,out int b)
  16. {
  17.  a = 5;
  18. b=7;
  19. }
  20.  
  21.  
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.
Mar 13 '08 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

4
by: Charles Jamieson | last post by:
I declare a class class myClass{ public: ~myClass();
0
by: John Baro | last post by:
I have a number of pictureboxes that I create dynamically and add a context menu for (One context menu for all of them). Is there any way to determine which control the context menu was invoked...
3
by: Wen | last post by:
hello, now, i wanna port a c++ program into C# project. a DLL written by C++ and keep it no change, and UI wirtten by C#. my C++ UI code is as below: // error handlers --global function...
1
by: John F | last post by:
Hello, I'm dynamically loading a child form saved in a DLL. I have this code working and it's pretty straightforward. What I'd like to do is pass an object type to an invoked method in the...
5
by: Bill | last post by:
This database has no forms. I am viewing an Access table in datasheet view. I'd like to execute a macro to execute a function (using "runcode"). In the function, I'll reading data from the record...
31
by: Zytan | last post by:
Everything (er, every class) in C# has ToString() which is conveniently automatically invoked when using it in Debug.WriteLine() or in a string concatenation, etc. I made a struct, and I want to...
9
by: johkar | last post by:
I need some browser implementation clarification. In the below example, the alternate stylesheet could be invoked by user agents that support alternate stylesheets or by script. Are there any...
13
by: sam_cit | last post by:
Hi Everyone, I have the following unit to explain the problem that i have, class sample { public : sample() { printf("in sample...\n"); }
7
by: Nick | last post by:
Hi there, Is it possible to tell how a WebMethod was invoked? For example I would like to determin if it was invoked via SOAP or HTTP Post. Other than creating 2 methods I am no sure if I can...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.