logo CodeStepByStep logo

ListMysteryRemove

Language/Type: C# List collections

What are the contents of the list after the following code executes?

List vec = new List();
for (int i = 1; i <= 8; i++)
{
    vec.Add(10 * i);   //   0   1   2   3   4   5   6   7
}                      // {10, 20, 30, 40, 50, 60, 70, 80}
for (int i = 0; i < vec.Count; i++) {
    vec.RemoveAt(i);
}
Console.WriteLine(vec);
list contents

You must log in before you can solve this problem.

Log In

Need help?

Stuck on an exercise? Contact your TA or instructor.

If something seems wrong with our site, please

Is there a problem? Contact us.