python - How to pass variable arguments to an Inner method in C# -


i have function in python uses function , args(tuple) input inner function: can replicate these using params , action innedmethod(). how wrap input variables (params) innermethod here? how can achieve this.

python

  def wrap_function(function, args):     ncalls = [0]     if function none:         return ncalls, none      def function_wrapper(*wrapper_args):         ncalls[0] += 1         return function(*(wrapper_args + args))      return ncalls, function_wrapper 

csharp : trying replicate above python function

private double objectivefunctionwrapper(ifunction f, tuple<list<double>, list<double>> args) {     int ncalls = 0;      action function_wrapper = () =>         {             ncalls = ncalls + 1;             f(params )         };     function_wrapper();     return ncalls; } 

to pass params[] array function argument, define method action<t> argument (instead of ifunction), , use bit of code:

public action<t> setparameters(action<object[]> action, params object[] parameters) {     return delegate { action(parameters) }; } 

Comments

Popular posts from this blog

javascript - jQuery: Add class depending on URL in the best way -

caching - How to check if a url path exists in the service worker cache -

Redirect to a HTTPS version using .htaccess -