Sending a method as a parameter

  • Thread starter Thread starter Guest
  • Start date Start date
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 );
}
 
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)
 
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).
 
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
 
Back
Top