Listnumbers = new List { 1, 2, 3, 4, 5 }; int thirdNumber = numbers.ElementAt(2); Console.WriteLine(thirdNumber); // Output: 3
ListThis example creates a List of strings and retrieves the element at index 3 using the ElementAt method. It then prints the value of the retrieved element to the console. The System.Windows.Documents namespace is part of the .NET Framework Class Library (FCL) and provides classes for creating and manipulating documents in Windows Presentation Foundation (WPF) applications.names = new List { "John", "Jane", "Bob", "Alice" }; string fourthName = names.ElementAt(3); Console.WriteLine(fourthName); // Output: Alice