这会有点复杂。我遗漏了一些事情让你去做。
String[] months = { "January", "February", "March", ....};
Date processDate = new Date();
while (!reader.EndOfStream)
{
string currentLine = reader.ReadLine();
// skip this line if blank
if (String.IsNullOrEmpty(currentLine)) continue;
if (months.Contains(currentLine)) {
// we have a new starting month.
// reset the process date
Int32 month = DateTime.ParseExact(currentLine.Trim(), "MMMM", CultureInfo.CurrentCulture).Month;
date = Convert.ToDate(month.ToString() + "/01/2013");
continue;
}
// here's where the real fun begins:
// you have to pull out the first two characters and test if one or both are digits.
// This will give you the day. Put that into your date variable.
Int32 day = 0;
char[] arr = currentLine.ToCharArray(0, currentLine.Length);
if (Char.IsDigit(arr[1])) {
// first two characters are numbers
day = Convert.ToInt32(currentLine.Substring(0,2));
currentLine = currentLine.Remove(0,2);
} else {
// only the first character is a number
day = Convert.ToInt32(currentLine.Substring(0,1));
currentLine = currentLine.Remove(0,1);
}
// set the new date
date = new DateTime(date.Year, date.Month, day, 0, 0, 0);
// If we can assume that ALL lines are broken into two parts then we can do the following:
String secondLine = reader.ReadLine();
currentLine = String.Format("{0} {1}", currentLine, secondLine);
// At this point you have the month, day, and the entire line.
// write it to your lunch stream or store in a StringBuilder
}