public int addEvent(string title) { Node temp = new Node(title); //add the event into list sorted by startTime if (eventList.Count != 0) { int j = 0; LinkedList<Node>.Enumerator e = eventList.GetEnumerator(); while (e.MoveNext() && j != 1) { trash1 = DateTime.Parse(temp.getStart()); trash2 = DateTime.Parse(e.Current.getStart()); if (trash1 <= trash2) { //check the end time if (!e.Current.checkRepeat(temp.getStart(), temp.getEnd())) { return -1; } //add to non-first and non-last point in list trash1 = DateTime.Parse(e.Current.getStart()); trash2 = DateTime.Parse(eventList.First.Value.getStart()); if (trash1 != trash2) { eventList.AddBefore(eventList.Find(e.Current), temp); return 1; } else { //add to first point in list eventList.AddFirst(temp); return 1; } } j = 1; } if (j != 1) { //add to end of list and check the end time if (!e.Current.checkRepeat(temp.getStart(), temp.getEnd())) { return -1; } eventList.AddLast(temp); return 1; } } eventList.AddFirst(temp); return 1; }