public static Message FindMessage(LinkedList<Message> messages, int index) { Message message = new Message(); int count = 0; Boolean found = false; foreach (Message Item in messages) { if (count == index) { found = true; message = Item; break; } count++; } if (found) return message; else return null; }
// Mutator method to add new messages public void Add(Message item) { messages.AddFirst (item); }