Search code examples
c#arrayscollectionsdynamic-arrays

Should I array or collection or what


my first post, so I hope I am keeping in the rules. I am converting to C# programming and I would appreciate being pointed in the right direction on this point. I have a stream of data consisting of integer pairs which I want to store. There could be between 15,000 and 250,000 pairs. Once they are collected I just need to read through the whole group - always all of them and the order is unimportant.

I have just got confused with all the options. in VBA I would use a collection of variant arrays


Solution

  • You could just use a List<Tuple<int,int>> to store your data, personally I would recommend a custom type though that gives meaning to each property (instead them just being Item1 and Item2).

    Using a list would be preferable to an array unless you know the exact number of items to store in advance.