private static string ConcatenateStudentExams(List <Grade> StudentsExams) { string result = ""; foreach (var item in StudentsExams) { // out of time use stringbuilder var courseNames = new DataAccessor().GetCourses(); var courseName = courseNames.FirstOrDefault(x => x.CourseId == item.CourseId).CourseName.ToString(); result += courseName + "||"; } return(result); }