I need to collect some data and temporarily store it in memory and then write it to a file.
At first I thought I could just use a Dictionary and made it all work, but when I finnsihed, I realized I need a third element in there, so Dictionarys is of no use I guess.
The three elements would be something like string name, bool asked, DateTime today.
When the function starts, I need to read a file where these elements are stored one per line, separated with a pipe.
As I am going through the function, I will need to add items if a condition evaluates to false in a foreach loop, or remove if the condition is true.
When the function is completed, I need to erase the file, and dump the contents of the array back to the file.
THe meaning would be like checking if John Doe has been asked if his task is completed yet and XX days has passed since he was last asked.
If XX days has passed, remove his record from the array, ask him again, and add new record to the array with todays date. (or simply, changed date in the array and ask again).
Then dump the contents of the array to the file so we can go through it again tomorrow.
I have never worked with arrays before though, so I have absolutely no clue of how to do this.. and when I search google I find a lot of examples, but none that really makes sense to me.
Could any of you let me know how you would proceed with this, as I am completely clueless.
As a more complete example, consider the following:
With this sample, you’re still using a Dictionary, so you can search by name. But the item data is all stored in the values. So you can do the following:
PS. This gets much easier with LINQ, but that’s probably a bit advanced for ya at this point.