Samuel Abels wrote:
Hello,

Consider this class:

-------------------------
public class FuncCaller
{
 public delegate void Function(object args);
 public Function function;
 public object   args;

 public FuncCaller (Function function_, object args_)
 {
  function = function_;
  args     = args_;
 }

 public void Call ()
 {
  if (!function || !args)
   return;
  function(args);
 }
}
-------------------------

The above class is supposed to hold a function, including all arguments,
and execute the call later.
However, I am looking for a way to pass *any* type of argument to the
constructor, rather then only variables of type "object". E.g.:

You're looking for something like that (untested):

class FuncCaller
{
  Delegate d;
  object[] args;
  public FuncCaller (Delegate d, params object[] args)
  {
    this.d = d;
    this.args = args;

  }

  public object Call ()
  {
    return d.DynamicInvoke (args);
  }
}

Rob

_______________________________________________
Mono-devel-list mailing list
Mono-devel-list@lists.ximian.com
http://lists.ximian.com/mailman/listinfo/mono-devel-list

Reply via email to