直接上C#代码
TimeSpan nowTime = DateTime.Now.TimeOfDay; string[,] arr = { { "7:50", "8:10" }, { "9:55", "10:15" }, { "13:55", "14:10" }, { "15:55", "16:10" }, { "18:55", "19:10" } }; for (int i = 0; i < arr.GetLength(0); i++) { TimeSpan srtTime = DateTime.Parse(arr[i, 0]).TimeOfDay; TimeSpan endTime = DateTime.Parse(arr[i, 1]).TimeOfDay; if (nowTime >= srtTime && nowTime <= endTime) { return "当前时间在指定时间时段内"; } }
标签:10,arr,超简版,TimeSpan,C#,DateTime,55,二维,TimeOfDay From: https://www.cnblogs.com/kandyvip/p/17774441.html