Pause the soccer application to compare the list’s current Count, indexed values, and object references with your prediction.
Use using System.Collections.Generic; at the top of the C# file, before its class definitions. Place the following statements inside an existing method.
List<int> roundGoals = new List<int>();
roundGoals.Add(2);
roundGoals.Add(0);
roundGoals.Add(3);
roundGoals[1] = 1;In Visual Studio, click the margin beside roundGoals[1] = 1; to set a breakpoint. Start debugging and run the application action that reaches this method. When it pauses on that statement, the correction has not executed yet.
Debug > Windows > Locals while paused inside the method.roundGoals and inspect Count and its current items. Depending on the debugger view, expand Results View to see indexed entries.Debug > Windows > Watch > Watch 1 and add roundGoals.Count and roundGoals[1]. Expect 3 and 0 before the correction.Step Over once to execute the assignment. The watched item becomes 1; Count stays 3.These examples use the established Player class and its public integer field NumberOfTurns. For a Player list, expand an item and inspect NumberOfTurns. If two entries refer to the same Player, changing its field through either entry is visible through both. Equal-looking field values alone do not prove two references reach the same object.