Re: int [] Array Question

Tech-Archive recommends: Repair Windows Errors & Optimize Windows Performance



Galahad <Galahad@xxxxxxxxxxxxxxxxxxxxxxxxx> wrote:
Ok that makes sense. I can't use an arraylist since the function only takes
int[] as a param.

In that case you should use the ToArray method of either ArrayList or
List<int> after you've created the list.

What is the syntax that I would use inside the loop to add the elements?

You can't add values to an array - arrays are fixed size. You'd have to
reallocate the array on each iteration, which is basically what
ArrayList/List<int> do, except they do it more efficiently by keeping a
buffer of unused entries, only resizing when they need to.

--
Jon Skeet - <skeet@xxxxxxxxx>
http://www.pobox.com/~skeet Blog: http://www.msmvps.com/jon.skeet
If replying to the group, please do not mail me too
.



Relevant Pages

  • Re: which is the better path
    ... The function should add each element in the array together and place ... summarrayreturns an int, why do you do with it? ... The size of arrays shoud be passed as a param. ... the proto for sumarray() should look like: ...
    (comp.lang.c)
  • Re: How to store floats in 4-byte format?
    ... back to a float. ... array stored in variable array. ... @param lpByteArr ... Convert an int value ...
    (de.comp.lang.java)
  • (patch for Bash) regex case statement
    ... Following up on my previous patch for regex conditional tests, ... /* Return an array of strings; ... int dollarflag, zeropad, compareflag; ... SHELL_VAR *var; ...
    (comp.unix.shell)
  • Re: Strategy or Iterator?
    ... It would be possible to write a class that returns the variations ... GNU General Public License for more details. ... protected CombinatoricOperator(Telements, int r) { ... An integer array backing up the original one to keep track of the ...
    (comp.lang.java.programmer)
  • (patch for Bash) regex conditional tests
    ... 'regex' are returned in array variable SUBMATCH. ... Skipping of positional parameters, array elements, string ... int dollarflag, zeropad, compareflag; ... SHELL_VAR *var; ...
    (comp.unix.shell)