Results 1 to 7 of 7

Thread: Better alternative than arrays?

  1. #1

    Thread Starter
    Member
    Join Date
    Jun 2008
    Posts
    47

    Better alternative than arrays?

    I'm using arrays because I have to deal with lists of items. I can't think of another alternative. Anyone know of one?

  2. #2
    I'm about to be a PowerPoster! Hack's Avatar
    Join Date
    Aug 2001
    Location
    Searching for mendhak
    Posts
    58,333

    Re: Better alternative than arrays?

    What about a control list a ListView or a ListBox?

  3. #3
    Fanatic Member
    Join Date
    Jun 2003
    Location
    Worcester, MA
    Posts
    782

    Re: Better alternative than arrays?

    If Hack's answer isn't sufficient could you give us some more information about what you're doing or maybe some code? I think your best alternative is generic lists... List<T>
    C#.net, VB, C++, Java, VS 2005/2008
    Dont' forget to rate posts that are helpful to you.

  4. #4
    Raging swede Atheist's Avatar
    Join Date
    Aug 2005
    Location
    Sweden
    Posts
    8,018

    Re: Better alternative than arrays?

    You'll have to provide much more information for us to give a good answer. For instance, why arent arrays sufficient for you? What are you storing?
    Rate posts that helped you. I do not reply to PM's with coding questions.
    How to Get Your Questions Answered
    Current project: tunaOS
    Me on.. BitBucket, Google Code, Github (pretty empty)

  5. #5

    Thread Starter
    Member
    Join Date
    Jun 2008
    Posts
    47

    Re: Better alternative than arrays?

    Basically, I'm handling and comparing file lists from directories. One list is a recorded old, the other is newly scanned. My process performs an operation if the new conflicts with the old.

    Mind you, these directories contain log files generated from processes that error out from time to time, usually one file out out of a period of 2-3 weeks.

  6. #6
    Fanatic Member
    Join Date
    Jun 2003
    Location
    Worcester, MA
    Posts
    782

    Re: Better alternative than arrays?

    I still don't think you're giving us enough to help you...

    Can you give us an example of a run of your program, or at least what you want it to do? It it comparing two "file lists" that are lists of the file's location or of its contents? And can you elaborate on "My process performs an operation if the new conflicts with the old". What exactly does that mean? Does conflict mean it contains the same or different information? And is that the file name or the contents?

    It might be just me but the descriptions given so far are much too vague to give any valuable feedback.
    C#.net, VB, C++, Java, VS 2005/2008
    Dont' forget to rate posts that are helpful to you.

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

    Re: Better alternative than arrays?

    An array is the most efficient way to store references to multiple objects of the same type such that you can enumerate the list or access individual items by numeric index. If that's what you want to do then arrays are most likely what you should use, assuming that the number of items in the list remains the same. You'll find that Directory.GetDirectories, Directory.GetFiles and the corresponding members of DirectoryInfo already return arrays.

    If your list changes size or accessing via a numeric index is not sufficient, then you need to look at some of the members of the System.Collections.Generic namespace, like List<T> and Dictionary<TKey, TValue>.
    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

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