Click here to Skip to main content
15,888,984 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I actually have multiple arrays that are populated with data as a console app in C# runs. What would be the best (computationally efficient) way to store the values to a file in a way that will be easy to access at any time by a program for processing. What then, would be the easiest, simplest, most efficient way to retrieve data from the these files (e.g. putting them back into an array for processing).

A big thank you from a poor excuse of a programmer.

What I have tried:

Basically I know how to store data in multiple arrays using while loops.
Posted
Updated 22-Aug-21 21:07pm
Comments
biorpg 20-Aug-21 20:17pm    
Are you asking how to best store the data temporarily while the remainder is processed, so that they can be recombined after a multi-threaded operation has completed?
BillWoodruff 20-Aug-21 21:36pm    
You need to think about ... and add information to your question about:

0) the type of array you want to save is a factor in choosing the save/serialize method. for example, you can't use XmlWriter to save arrays with more than one dimension.

1) saving individual arrays and reloading them from a file vs. saving all arrays and reloading them

2) why are you using a console app: what is the source of the data you store in the arrays ... user input from keyboard ?

"A big thank you from a poor excuse of a programmer." This kind of appeal to emotion is likely to make people here not want to respond to you.

More detail, please.

The simplest way is probably to use JSON or XML - I prefer JSON, and use the Json.NET - Newtonsoft[^] package to make it simple: read and / or write the whole array regardless of the element type in one line of code.
 
Share this answer
 
You can also use CSV data file format.
Best regards
 
Share this answer
 
Comments
Admin BTA 23-Aug-21 7:31am    
Ah Thanks! I am very familiar with CSV, I love this idea. How would I add or retrieve data from the CSV file in C#? In other words how would I get my data from my array to the file and vice versa? Thanks! :)
Member 12699051 24-Aug-21 3:54am    
search in Nuget packages. I think you can find code on this site.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900