Hi I am in a bit of an issue I keep getting this error:
Index was outside the bounds of the array.
var d = File.ReadAllLines(@"studentsFile.txt");
var t = d.Where(g => g.Contains("Student Name"));
string[] splited;
foreach (var item in t)
{
splited = item.Split(new string[] { "Student Name:" }, StringSplitOptions.None);
cbListStudents.Items.Add(splited[1]);
}
The above works perfectly but the code below does not:
var cour = File.ReadAllLines(@"CourseFile.txt");
var courFind = cour.Where(g => g.Contains("Course"));
string[] splited2;
foreach (var item in courFind)
{
splited2 = item.Split(new string[] { "Course:" }, StringSplitOptions.None);
cbListCourses.Items.Add(splited2[1]);//here is where the issues starts
}