proper way to store unknown number of object instances?

Jan 17 2004 9:52 PM
What is the proper way (or any way) to store the reference to an unknown number of object instances in C#? Let say I have a class called Widget and I want to make a lot of instances of Widget and keep track of them all, the number of them depending on how many a user needs/creates. If I store all the instance references in an array, I have to declare ahead of time how many there are so that doesn't seem to work. I'm used to languages that allow me to just add dynamically to an existing array so I don't have to worry about how many of something I am going to store. How do I do this in C#? Sorry for a question so basic.

Answers (4)