Put simply,
List<int> processedList = new List<int>();
Creates processedList and assignes a new, empty list to it.
processedList = (List<int>) Session["processedUsers"];
Replaces the empty list with whatever the cast returns.
if(processedList.Count != 0)
Uses the list contained in processedList to check the number of entries.
So if
Session["processedUSers"]
does not return a list then:
if it returns a non-list item it will throw a "cannot convert" exception.
if it returns a null,
processedUsers
will become null, and the empty list you assigned will be discarded.
If
processedUsers
is null, then attempting to access any element, even the items count, will give a null reference exception.
So: Check what
Session["processedUSers"]
is returning, and make sure that
processedItems
is a valid list before you try and use3 it.