Mngaro Mwazenje

Mngaro Mwazenje

  • NA
  • 80
  • 12.2k

public static void RemoveLast(List<string> strings)

Feb 20 2020 3:35 PM

Create the method public static void RemoveLast(List<string> strings) in the exercise template. The method should remove the last value in the list it receives as a parameter. If the list is empty, the method does nothing.

List<string> strings = new List<string>();  
strings.Add("First"); 
strings.Add("Second"); 
strings.Add("Third");  
// Remember, this is how you print all the items in a list 
strings.ForEach(Console.WriteLine);  
RemoveLast(strings); 
RemoveLast(strings);  
strings.ForEach(Console.WriteLine);

Answers (5)