3

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)
Lews Therin
  • 3,707
  • 2
  • 27
  • 53
PopperJuan
  • 175
  • 1
  • 16

1 Answers1

4

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())
Steven Doggart
  • 43,358
  • 8
  • 68
  • 105
  • @Fabio Well, that depends on whether or not you would refer to an array as a "list". Arrays do contain a list of items, so in a general way they are. But also, since in the .NET Framework, arrays actually do implement the `IList` interface, it's also rather technically accurate to refer to them as lists too. :) – Steven Doggart Oct 16 '15 at 20:57
  • thanks @StevenDoggart This has saved me hundreds of lines of code, I didn't think about it that way :) – PopperJuan Oct 19 '15 at 19:46