Array question

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • y

    #1

    Array question

    Hi,

    I am trying to return an array from a method and assign
    then returned array to the calling method.

    I am not sure why this error is coming up.

    string [] arr_Selected = new string[100];

    arr_Selected = AddToArray (arr_Selected, strSelectedID);

    Thanks,
    y

  • Frank Oquendo

    #2
    Re: Array question

    y wrote:
    [color=blue]
    > I am not sure why this error is coming up.[/color]

    What error?
    [color=blue]
    > string [] arr_Selected = new string[100];
    >
    > arr_Selected = AddToArray (arr_Selected, strSelectedID);[/color]

    Reduce the second line of code to this:

    AddToArray(arr_ Selected, strSelectedID);

    Since you're passing a reference to the array, there's no need to return
    it or reassign it.

    --
    There are 10 kinds of people. Those who understand binary and those who
    don't.




    Comment

    Working...