2 回答
TA贡献1829条经验 获得超13个赞
string delimiter = ",";
string sTimeUpper = "2017-04-25 14:16:30.000";
string sTimeLower = "2017-04-25 14:15:30.000";
DateTime TimeUpper = DateTime.Parse(sTimeUpper);
DateTime TimeLower = DateTime.Parse(sTimeLower);
Console.WriteLine($"TimeLower = {TimeLower}");
Console.WriteLine($"TimeUpper = {TimeUpper}");
List<string> res = (File.ReadAllLines(@"TimeStamp.txt")
.Skip(1)
.Select(line => line.Split(delimiter.ToCharArray(), StringSplitOptions.RemoveEmptyEntries))
.Where(fields => DateTime.Parse(fields[3]) > TimeLower && DateTime.Parse(fields[3]) < TimeUpper)
.Select(fields => string.Join(",", fields))
.ToList<string>());
Console.WriteLine("Requested readings:");
foreach (string item in res)
{
Console.WriteLine(item);
}
- 2 回答
- 0 关注
- 247 浏览
添加回答
举报