vb.netmethodsparamarray

Can you pass a list in an ParamArray parameter


I'm was wondering if you can pass a list into a parameter of ParamArray in a method? For ex.

dt = ws.getTable("baseDivision.code:1",
    "countryCode:CA",
    "status.code:[1+TO+6]",
    "buType.code:(6+7+8+88)",
    "market.code:[0+TO+*]",
    "region.code:[0+TO+*]",
    "!subDivision.code:null",
    "openDate:[*+TO+NOW%2B1MONTH]")

Instead of passing these parameters can you pass a list of strings where each elements contains these parameters.

So kinda like this

dt = ws.getTable(aListOfStringParamters)

Solution

  • Yes, but the argument must be an array. If the argument is some other kind of enumerable list, then you can use LINQ's ToArray extension method to convert it:

    dt = ws.getTable(aListOfStringParamters.ToArray())