On my app a teacher can have several classes, and when I exclude a teacher's profile I have to, first, delete his classes. I'm trying to put each
int x = 0;
int count = new int[x];
if(x != 0)
count = new int[x];
count[x] = _class.Class_id = reader_SelectedClasses.GetInt16("class_id");
select class_id from tbl_class where user_id = " + id + ";
You need to learn how to use a debugger and step through your program.
count = new int[x]; discards what was in
count and creates a new empty array that contains nothing. This array's indexes go from 0 to
x - 1.
count[x] = ... sets the array element at index
x which according to the previous line is one past the end of the array.
You need to set
count = new int[x] only once, at the beginning of your program, and set
count[x] = ... only if x >= 0 and x < count.Length.