2022-07-25

c# - how to pass function as parameter (with parameters as values) without invoking it

I want to pass a function as a parameter to another function (with actual values) and later execute it. Here is JavaScript code:

function functionToPass1 (x,y) {
    console.log(x, y);
}

function functionToPass2 (x,y,z) {
    console.log(x, y, z);
}

function mainFunction(param1, param2, functionToPass){
  console.log(param1, param2);
  functionToPass();

}

mainFunction("a", "b", function(){
    functionToPass2(1, 2, 3) ;
});

How to write this in C# (or VB.Net)?



No comments:

Post a Comment