I'm using arrays because I have to deal with lists of items. I can't think of another alternative. Anyone know of one?
Printable View
I'm using arrays because I have to deal with lists of items. I can't think of another alternative. Anyone know of one?
What about a control list a ListView or a ListBox?
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>
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?
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.
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.
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>.