Sending a method as a parameter

G

Guest

Hi,

How can I send a method as a parameter to be executed in a class?
If possible without using delegate.

public void MethodA()
{
// Code
}

public void ExecuteMethod( * MethodParam )
{
// Invoke the method parameter
**MethodParam.invoke();
}

public void main()
{
// Call ExecuteMethod sending MethodA as a parameter
ExecuteMethod( * MethodA );
}
 
L

Lau Lei Cheong

That's what delegate function is invented for. :)

You can assign a function PROTOTYPE as parameter, and accept a function that
"accept that kind of parameter" as parameter. (not intented pun)
 
L

Lau Lei Cheong

Ar, I overlooked the question...

If it's C/C++, there's a type of function called CALLBACK function. (The
WinProc in Classic C-style Windows program is an obvious one)

But I think that's similar to delegate anyway(delegate is invented to get
rid of pointers I believe).
 
G

Guest

Sorry about the missing information.
I talking about NET2005 C#.
I could you explain it a little more? What do you mean by that?
Maybe a sample?

Thank you,
Roby Eisenbraun Martins
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top