Results 1 to 3 of 3

Thread: [3.0/LINQ] add to an existing array

  1. #1

    Thread Starter
    Fanatic Member Crash893's Avatar
    Join Date
    Dec 2005
    Posts
    930

    [3.0/LINQ] add to an existing array

    I know this is probably prety noob of me but im having a brain fart


    In useing .net 3.0 i want to add to an array in a loop but as it is now i just over write the array each time the loop goes through.


    ive been pokeing around and i dont see .add some im wondering what i should be looking for

    thanks

  2. #2
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    111,221

    Re: [3.0/LINQ] add to an existing array

    Arrays are fixed size. If you want to make an array grow you have to create a new array with the desired size and copy all the elements from the existing array to the new one. The Array.Resize method will do that for you but that's not something you should be doing too often. It's quite time consuming, especially with larger arrays. If you want a "dynamic array" then you should be using a List<T>, which exists specifically for the purpose.
    Why is my data not saved to my database? | MSDN Data Walkthroughs
    VBForums Database Development FAQ
    My CodeBank Submissions: VB | C#
    My Blog: Data Among Multiple Forms (3 parts)
    Beginner Tutorials: VB | C# | SQL

  3. #3

    Thread Starter
    Fanatic Member Crash893's Avatar
    Join Date
    Dec 2005
    Posts
    930

    Re: [3.0/LINQ] add to an existing array

    10-4

    thanks I'll give it a try

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