[Solved] C# ASP arraylist gets cleared [closed]


The reason your statement fails is that you are trying to access elements beyond the collection’s bounds. When iterating through programEvents, you are assigning indexes to evectr ranging from 0 to programEvents.Count inclusive. However, since indexing is zero-based, the index of the last element is actually programEvents.Count - 1; accessing programEvents[programEvents.Count] would throw an IndexOutOfRangeException.

You need to replace:

for (int evectr = 0; evectr <= programEvents.Count; evectr++)
{
    paramID = programEvents[evectr];

…with:

for (int evectr = 0; evectr < programEvents.Count; evectr++)
{
    paramID = programEvents[evectr];

1

solved C# ASP arraylist gets cleared [closed]