Question: 2. What is wrong with the following code? C# List collection = new List (); // do some work to put a lot of items

2. What is wrong with the following code?

C#

List collection = new List(); // do some work to put a lot of items into the list string valueToWrite; for(int loopCounter = 0; loopCounter <= collection.Count; loopCounter++) { valueToWrite += collection[loop]; // do some more work } 

VB

Dim collection As New List(Of String) ' do some work to put a lot of items into the list Dim valueToWrite as String For loopCounter As Integer = 0 To collection.Count valueToWrite += collection(loop) ' do some more work Next 

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!