using linq its:
var dates = File.ReadAllLines(@"d:\Downloaded Images\Dates\dates.txt").Select(d => DateTime.Parse(d)).ToArray();
This browser is no longer supported.
Upgrade to Microsoft Edge to take advantage of the latest features, security updates, and technical support.
In the top of form1I have a List type DateTime
private List<DateTime> dates = new List<DateTime>();
at some point in my code I save the dates in the List to a text file
dates = rad.dates;
StreamWriter w = new StreamWriter(@"d:\Downloaded Images\Dates\dates.txt");
int i;
for (i = 0; i < dates.Count - 1; i++)
{
w.WriteLine(dates[i]);
}
w.Write(dates[i]);
w.Close();
The result is a text file with dates like this
After saving the dates to the text file I want to read back the dates to the dates list in the constructor
I read lit like this
string[] dates = File.ReadAllLines(@"d:\Downloaded Images\Dates\dates.txt");
The problem is that it's string array type and not DateTime list and I also want to assign it to the existing DateTime dates List and not to a new variable.
using linq its:
var dates = File.ReadAllLines(@"d:\Downloaded Images\Dates\dates.txt").Select(d => DateTime.Parse(d)).ToArray();