when i run my code and enter an input my code throws an exception index outside bounds of array here is my code
public static void ShowDiscription()
{
Console.WriteLine("Enter Course ID: ");
string ReqCourseID = Console.ReadLine();
Console.WriteLine();
if (Program.AllCourses.ContainsKey(ReqCourseID))
{
FileStream FS = new FileStream("Description.txt", FileMode.Open);
StreamReader SR = new StreamReader(FS);
while (SR.Peek() != -1)
{
string z = SR.ReadLine();
String[] Fields;
Fields = z.Split('@');
string courseName = Fields[0];
string coursedescription = Fields[1];
if (ReqCourseID.CompareTo(Fields[0]) == 0)
{
Console.WriteLine(Fields[1]);
SR.Close();
return;
}
}
}
else {
Console.WriteLine("Entered Course ID is not found! press any key to continue");
}
}
i dont know whats the problem the file has a delimter @ which divides the subject code and its description. does it differ if the description.txt file is too large? Regards