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:
In the starter project, add code to the List_Basics
class, so that the RunExercise
method does the
following:
Create a List<>
object that will
store int
s, make sure that the
starting capacity is 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.
Display the contents of the list to the screen using another for
(or foreach
) loop.
When deciding whether your loop should
run an additional time, make sure that you
use the .Count
property on the
List<>
.
Once you’ve done that, try doing this all again, a
second time, this time storing string
objects instead of int
s.