Learner
Learner

Reputation: 563

Pass array as a parameter to another

I have a code snippet. & i wanted to pass msg_arr as a parameter,array name is msg_arr

Here is my try 1,but getting eror

 private void check(string keyword params arr[] msg_arr )
    {
        switch (keyword.ToUpper())
        {
            case  "SETTELG":
                Response.Redirect("../SMSFunction/SeenSMS.ascx?value=1&arr" + msg_arr);

                break;

Here is my try 2,also error

 private void check(string keyword string msg_arr[] )
    {
        switch (keyword.ToUpper())
        {
            case  "SETTELG":
                Response.Redirect("../SMSFunction/SeenSMS.ascx?value=1&arr" + msg_arr);

                break;

Upvotes: 1

Views: 250

Answers (2)

Sunny
Sunny

Reputation: 3295

Hi Learner,

Please use this signature

 private void check(params object[] msg_arr)
{

}

it works for me hope it also help you

Upvotes: 0

alexn
alexn

Reputation: 58962

Well, you are missing a comma between the parameters:

private void check(string keyword, params arr[] msg_arr)

If that's not the case, please post the whole code and the actual error message. A good idea is to read the documentation on params.

Upvotes: 5

Related Questions