private void executemethod(object parameter) { var values = (object[])parameter; string name = (string)values[0]; bool check = (bool)values[1]; if (check) { LessonList.Add(name); } else { LessonList.Remove(name); } var rawList = new List <int>(); foreach (string l in LessonList) { int lesson = int.Parse(l); rawList.Add(lesson); } rawList.Sort(); Lessons = ""; foreach (int item in rawList) { string l = item.ToString(); Lessons += l; Lessons += "., "; } }