Trying to run through a dictionary string and write the contents to file that should be easy on the eyes.
Dictionary<CArray, string> dictCArray = new Dictionary<CArray, string>();
DateTime dtmPad = DateTime.Today;
for (int i = 0; i < s1.Length / 2; i++)
{
CArray caobject = new CArray();
dictCArray.Add(caobject, s1[i, 0]);
for (int x = 0; x < idatelength; x++)
{
caobject.dtmday = dtmPad.AddDays(x);
caobject.s2 = Create(ilength);
caobject.s3 = s1[i, 1];
caobject.dictC.Add(caobject.dtmday, caobject.s2);
}
}
Where CArray is a class with two strings and a dictionary that contains a datetime and a string.
class CArray
{
public DateTime dtmday;
public string s2;
public string s3;
public Dictionary<DateTime, string> dictC = new Dictionary<DateTime, string>();
}
I need a way to run through it and output it to a file, and also have the ability to read that file back into the same format. I am just stumped on how to do it. Any help would be appreciated.
You should look into serialization. All you’ll need to do is implement two functions for your custom class.
A note: This won’t make easy-to-read files, but it will work well for saving/loading from files.