using System.Collections.Generic;
private static Random r = new Random();
private static List<int> theList;
private static int largestElement;
public static void Main()
theList = new List<int>();
for(int i = 0; i < 20; i++) {
theList.Add(r.Next(1, 101));
largestElement = GetLargestElement(theList);
foreach(int i in theList) {
Console.Write(string.Format("{0} ", i));
Console.WriteLine("\nThe largest element inside the list is " + largestElement);
public static int GetLargestElement(List<int> list) {