I am trying to make a small app that uses a multiple hierarchy of type List within a List for some 20-30 levels. I tried with:
System.Collections.ComponentModel.ObservableCollection, but at run time, I got an OutOfMemoryException error. Then, I tried with List, and this time I did not get such an error.
What type of collection consumes the least amount of space? Or, what would be a good way to achieve this type of hierarchy? I just need a collection; I don’t need change notifications, etc. I am using .NET 4 with VB, Linq, and WPF. I achieved the code looping process with Parallel.ForEach threading.
Edit:
The Program is for string the file system data into Sql CE DB and retrieving it back. Hence, the hierarchy can be of 20-30 levels also.
Edit: There would be about 80000 Queries with linq for getting the hierarchy. The Type of data I am using is as follows:
Public Structure FileRecord
Property ID As String
Property Namee As String
Property Size As String
Property IsFolder As Boolean
Property DateModified As Date
Property FullPath As String
Property Disk As String
Property ParentID As String
Property Items As List(Of FileRecord)
End Structure
The performance characteristics of the various .NET collection classes vary widely, and the type of collection you’ll want to use will also depend on how you will want to access the collection. As usual, there are trade-offs to be made between performance (in time and memory) and simplicity or convenience.
That said, one of the simplest and most performant collection types in .NET is probably Array.