Answer the question
In order to leave comments, you need to log in
How to store objects?
Hello! I am writing a program in C#. Many objects of my class will be created, let's say My_Class. Where should I store them then? For example, in C ++ there was a Vector in which they could be stuffed. And how to do it in Sharpe?
Answer the question
In order to leave comments, you need to log in
I'm not a C# expert, but it seems like System.Collection.Generic.ArrayList (similar to std::vector) and System.Collection.Generic.List (similar to std::list)
The question is not specific. Do you need to store objects while the program is running, or between runs? How often will these objects be accessed? What will be more: writing or reading?
If the issue is storage during the execution of the program, then List, Dictionary and just arrays. Queue and Stack are also available. I recommend using generalized options, i.e. List, Dictionary, i.e. parameterized by type.
From the point of view of architecture - in the data access layer. Create a thread decorator that works with the store and forward - all your objects there. Let the decorator implement some thread of the ICollection interface. So you will have Add, and Remove, and Get and GetAll. You can even make it static - let it be available from anywhere.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question