[Mono-list] params and reflection

Andreas Färber andreas.faerber at web.de
Sun Aug 13 20:25:53 EDT 2006


Hi,

How do I correctly invoke a method with a params (vararg) argument?


Assuming a method

void X(object arg1, params object[] args) { }

...do I need to call it with object[2] where the second element would  
be another object[], oder do I need to call it with object[1+n] where  
n==args.Length?

...do I need to specify BindingFlags.OptionalParamBinding or not?

...should I use MethodInfo.Invoke or Type.InvokeMember or ...?


The docs are a little sparse on that topic, and trying all kinds of  
combinations has only shown weird behavior so far...

So, any hints are highly appreciated!

Regards,

Andreas


More information about the Mono-list mailing list