I am reading a text file to a list and, adding line numbers to the output. I want to search for a date in the format of MM/Day/Year and output it to console. If the next date in the text file is the same as the last one found then I do not want to output it, I only want to output the date that is later than the last. I am new to programming and have searched the site for date search code but haven't found something I understand. Here is my current code.
internal class LineInformation
{
public int Index { get; set; }
public string Line { get; set; }
}
static void Main(string[] args)
{var fileName = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "doc.txt");
var theWholeFile = File.ReadLines(fileName)
.Select((line, index) => new LineInformation { Line = line, Index = index }).ToList();
Now I don't know how to search specifically for the aforementioned date format and write it to console. How would I declare a date format like MM/Day/Year then say something like;
if(line.Contains(date)=>1stdate)
{Console.WriteLine(date)}