public static void printListInformation(LazyList list) { Console.WriteLine("Enter the index of the element: "); int index; bool invalid = false; if (!int.TryParse(Console.ReadLine(), out index)) { invalid = true; } else if (index < 0) { invalid = true; } if (invalid) { Console.WriteLine("Invalid input!"); Console.WriteLine("Press any key to continue."); Console.ReadKey(); return; } Console.WriteLine("list[{0}] = {1}", index, list.Element(index)); Console.WriteLine("Size of the list is {0}", list.Size()); Console.WriteLine("Press any key to continue."); Console.ReadKey(); }