I read the article at MSDN (http://msdn.microsoft.com/en-us/library/6tc79sx1.aspx) about selecting a collection class, but I don't understand any better. I am converting a VBA Access program to C#. I have a class that represents a document and the various parts of a document. I want to be able to add each document to a collection. In VBA it was difficult because you had to create a unique ID for each instance and then add it to the collection. So I created a class and the parameters. Do I have to create a unique ID for the collection? I want to be able to sort the members of the collection by a date. I want to be able to do a "For each" type of operation on the collection. There should not be a lot of work in the class since it is just an instrument that will eventually be put back into the database.
I am using "using System.Collections.Generic" with parameters such as public string Volume {get; set;}.
Be gentle with me. I have never used C# before! I have read a lot of stuff, but I still need some guidance.
Visual Studio Professional 10, Windows 7.
If you think I am going about this the wrong way please ask questions so I can better explain myself.
Thanks for the input!
Scott
Loading
VulpesPosted Feb 13, 2012, 2:58 PM
However, it sounds to me like a generic List should suffice. This is basically a dynamic array - an array which increases its size automatically as new elements are added. Individual elements can be accessed in the same way as an array starting at index 0.
You can easily add the ability to sort your documents in any way you wish by implementing the generic IComparable interface.
You can also use foreach to iterate through the elements of the List.
The following simple example may help you to get going:
Sam HobbsPosted Feb 13, 2012, 5:42 PM
FroglegPosted Feb 13, 2012, 3:25 PM