This line is (most probably) faulty:
if(itemtypescollecitons[i].ToString() != null)
Because if
itemtypescollecitons[i]
is
null
then you can't call
ToString()
on it: It will throw a NullReference-exception. You surely meant to write this instead:
if(itemtypescollecitons[i] != null)
Sidenote: The default implementation of
ToString()
never returns
null
. (And an overridden implementation never should.)
No guarantee that this is the only problem. If it's not, follow OriginalGriff's advice and also follow it in the future when you encounter this or another problem that you can't quickly figure out by looking at the code.