S
S
Sergey Polyntsev2014-12-23 06:45:13
Programming
Sergey Polyntsev, 2014-12-23 06:45:13

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

4 answer(s)
S
sanchas, 2014-12-23
@The_Chemis

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)

P
Pavel Elizariev, 2014-12-23
@effetto

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?

C
Cyril, 2014-12-23
@teoadal

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.

H
haiku, 2014-12-23
@haiku

"Lot"? Subjective criterion. How much specifically? Hundreds/thousands/tens of thousands?
Sharpe lacks any List, Array, Dictionary, Set, Tuple, LinkedList, etc. etc.
Choose appropriate for the task at hand. As a replacement for a vector, List will do just fine.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question