Let's do a warm-up exercise by creating a list of party members in a fictional role-playing game:
- Create a new List of the string type, called questPartyMembers, and initialize it with the names of three characters.
- Add a debug log to print out the number of party members in the list using the Count method.
- Save the file and Play it in Unity:
We initialized a new list, called questPartyMembers, which now holds three string values, and used the Count method from the List class to print out the number of elements:
Knowing how many elements are in a list is highly useful; however, in most cases, that information is not enough. We want to be able to modify our lists as needed, which we'll discuss next.