1 List<ObservePoints> pointsInRectangle = new List<ObservePoints>(); 2 3 IEnumerable<ObservePoints> query = null; 4 query = from items in pointsInRectangle orderby items.MonitorTime select items; 5 6 foreach (var item in query) 7 { 8 sw.WriteLine(item.MonitorTime.Year.ToString() + "-" + 9 item.MonitorTime.Month.ToString() + "-" + 10 item.MonitorTime.Day.ToString() + " " + 11 item.MonitorTime.Hour.ToString() + "-" + 12 item.MonitorTime.Minute.ToString() + "-" + 13 item.MonitorTime.Second.ToString() + "," + 14 item.X.ToString("0.000") + "," + 15 item.Y.ToString("0.000") + "," + 16 item.Z.ToString("0.000")); 17 }
其中 pointsInRectangle为集合链表,对其按时间顺序排序,并写入文件