Dragon
Dragon

Reputation: 85

Allow parameter to have more than one value? for example value 1|| value 2 (C#,Light switch)

in my project "Light switch C#", I have a button which take me to a certain screen. The screen take one parameter of type string, for example "Office-Italy","Office- Germany"

My code:

enter code here
   partial void HQ_Execute()
    {
        // Write your code here.
        this.Application.ShowPart_1_SearchBalanceGreaterZero("IC-MOS");

    }

now the question here is, I have 12 office and when I press the HQ (Head office) button I want my filter to be something like *. in other words I want my filter to have this value

this.Application.ShowPart_1_SearchBalanceGreaterZero("IC-MOS"||"IC-IT")

is this possible by anyhow?

Thanks a lot, Zayed

Upvotes: 0

Views: 152

Answers (2)

Rahul
Rahul

Reputation: 77876

Other than what have been already mentioned in Jon's answer; you can pass your value as a single string and in destination method break and parse them accordingly. Something like

this.Application.ShowPart_1_SearchBalanceGreaterZero("IC-MOS|IC-IT")

In your method body

void ShowPart_1_SearchBalanceGreaterZero(string data)
{
  string[] strarr = data.Split('|');

  //now use the data string array the way you want
}

Upvotes: 0

Jon Skeet
Jon Skeet

Reputation: 1500845

No, a parameter can't have more than one value. So you'll need to change your method to accommodate what you need, e.g. by changing the parameter so that it's a collection of strings instead of a single string.

You could change the implementation instead, e.g. to allow you to pass "IC-MOS,IC-IT" and split it by commas - but it's clearer (IMO) to specify the values separately.

Upvotes: 2

Related Questions