Results 1 to 3 of 3

Thread: [RESOLVED] [02/03] assigning a subset of an array in a single stmt

  1. #1

    Thread Starter
    Lively Member
    Join Date
    Jun 2007
    Posts
    115

    Resolved [RESOLVED] [02/03] assigning a subset of an array in a single stmt

    say i have two arrays, array1 and array2

    array1 has 20 elements and array2 has 5 elements

    i wish to assign array1 elements 0-4 to array2

    can i do this in a single statement?

    something like this though i don't think syntax is correct for vb:
    Code:
    array2=array1(0:4)

  2. #2
    Still learning kebo's Avatar
    Join Date
    Apr 2004
    Location
    Gardnerville,nv
    Posts
    3,762

    Re: [02/03] assigning a subset of an array in a single stmt

    Try Array.Copy (Array, Array, Int32)
    From MSDN
    Copies a range of elements from an Array starting at the first element and pastes them into another Array starting at the first element. The length is specified as a 32-bit integer.

    Supported by the .NET Compact Framework.
    Process control doesn't give you good quality, it gives you consistent quality.
    Good quality comes from consistently doing the right things.

    Vague general questions have vague general answers.
    A $100 donation is required for me to help you if you PM me asking for help. Instructions for donating to one of our local charities will be provided.

    ______________________________
    Last edited by kebo : Now. Reason: superfluous typo's

  3. #3

    Thread Starter
    Lively Member
    Join Date
    Jun 2007
    Posts
    115

    Re: [02/03] assigning a subset of an array in a single stmt

    Quote Originally Posted by kebo
    Try Array.Copy (Array, Array, Int32)
    From MSDN

    Thanks. Exactly what I was looking for. And just to expand a bit in case anyone else looks at this thread. It can take a different number of parameters for more flexiblilty.

    Array.Copy(sourceArray, sourceIndex, destinationArray, destinationIndex, length)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width