List<> Basics: Declaring and Using a Simple List<>

The goal for this exercise is to make sure that you can create a simple List<>, and both put values into it, and get values back out of it.

What you need to do to prepare for this exercise:


What you need to do for this exercise
  1. In the starter project, add code to the List_Basics class, so that the RunExercise method does the following:

    1. Create a List<> object that will store ints, make sure that the starting capacity is 2

    2. Use a for loop to initialize the List with user input from the keyboard.
      Make sure to get exactly 5 integers from the user
      (the goal here is to make sure that you can both add stuff to the List<>, and also to run code that will force the List<> to resize the underlying array for you.

    3. Display the contents of the list to the screen using another for (or foreach) loop.

      1. When deciding whether your loop should run an additional time, make sure that you use the .Count property on the List<>.

  2. Once you’ve done that, try doing this all again, a second time, this time storing string objects instead of ints.