5

how to pass argument as function

1

2 Answers 2

6

You're probably looking for delegates.

public delegate void MyDelegate(int myInt, string myString); public void FunctionToCall(int i, string s) { Console.WriteLine(s + " [" + i.ToString() + "]"); } public void MethodWithFunctionPointer(MyDelegate callback) { callback(5, "The value is: "); } 

And then, to call it:

MethodWithFunctionPointer(FunctionToCall); 
Sign up to request clarification or add additional context in comments.

Comments

1

Make argument as delegate, and call function with address of function which should match with delegates

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.