Results 1 to 6 of 6

Thread: Pass part of an array

  1. #1

    Thread Starter
    Fanatic Member
    Join Date
    Jul 2003
    Posts
    830

    Pass part of an array

    Can you pass part of an array?

    For example, if I have an array of 4....can I pass the first half and then the second half in to a function? What I mean by half is like the first two elements and then the second two.

    Hope this is clear enough for a general answer.

    Thanks!

  2. #2
    Sleep mode
    Join Date
    Aug 2002
    Location
    RUH
    Posts
    8,083
    Well , I don't think so . An array is contiguous cells allocated in the memory identitified by one name . As a workaround , you can make temp array that hold two elements and copy from the source just the two .

  3. #3
    PowerPoster sunburnt's Avatar
    Join Date
    Feb 2001
    Location
    Boulder, Colorado
    Posts
    1,403

    Re: Pass part of an array

    You could use unsafe code and pass a pointer to the first elements in each section. A better solution would be to have each function take the the array, a start, and length arguments to determine where it should get its arguments from.
    Every passing hour brings the Solar System forty-three thousand miles closer to Globular Cluster M13 in Hercules -- and still there are some misfits who insist that there is no such thing as progress.

  4. #4
    Sleep mode
    Join Date
    Aug 2002
    Location
    RUH
    Posts
    8,083
    Just to clear something up , I was talking in a managed code view point.

  5. #5
    PowerPoster sunburnt's Avatar
    Join Date
    Feb 2001
    Location
    Boulder, Colorado
    Posts
    1,403

    Re: Pass part of an array

    Quote Originally Posted by Pirate
    Just to clear something up , I was talking in a managed code view point.
    Which is definently a better option. There's no reason to use unsafe code for something like this where you could design it better using a managed solution. I was just throwing that out there
    Every passing hour brings the Solar System forty-three thousand miles closer to Globular Cluster M13 in Hercules -- and still there are some misfits who insist that there is no such thing as progress.

  6. #6
    l33t! MrPolite's Avatar
    Join Date
    Sep 2001
    Posts
    4,428

    Re: Pass part of an array

    try the Array.GetValue (params long[] indecies) method.
    rate my posts if they help ya!
    Extract thumbnail without reading the whole image file: (C# - VB)
    Apply texture to bitmaps: (C# - VB)
    Extended console library: (VB)
    Save JPEG with a certain quality (image compression): (C# - VB )
    VB.NET to C# conversion tips!!

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