生徒と科目の詳細を取得するためのギザギザ配列があります。2 つのギザギザ配列を使用しました。特定の学生の場合、どうすればそれを実行できるか教えてもらえますか。以下は私のコード全体です。
public void GetStudentDetails()
{
Console.WriteLine("Please enter number of Students");
int STUDENTS = Convert.ToInt32(Console.ReadLine());
Console.WriteLine("Please enter number of Subjects");
int SUBJECTS = Convert.ToInt32(Console.ReadLine()); //0 is reserved for the student name, so the marks starts from the index 1, hence if you set the marks for 3, it will ask for 2 marks
string[][] student_details = new string[STUDENTS][];
string[][] subject_details = new string[SUBJECTS][];
string[][] result_details = new string[STUDENTS][];
StringBuilder stud_sub_info = new StringBuilder();
stud_sub_info.Append("Name\tRoll-No\t");
for (int a = 0; a < STUDENTS; a++)
{
student_details[a] = new string[STUDENTS * 2];
for (int b = 0; b < 2; b++)
{
Console.WriteLine("Enter Student {0} {1}:", a + 1, (b == 0) ? "Name" : "Roll-No");
student_details[a][b] = Console.ReadLine();
}
for (int c = 0; c < SUBJECTS; c++)
{
subject_details[c] = new string[SUBJECTS * 2];
for (int d = 0; d < 2; d++)
{
if (d == 0)
{
Console.WriteLine("Enter Name for Subject {0}", c + 1);
subject_details[c][d] = Console.ReadLine();
stud_sub_info.Append(subject_details[c][d] + "\t");
}
else
{
Console.WriteLine("Enter Marks for {0}", subject_details[c][d - 1]);
subject_details[c][d] = Console.ReadLine();
}
}
}
}
Console.WriteLine(stud_sub_info.ToString());
for (int a = 0; a < STUDENTS; a++)
{
for (int b = 0; b < 2; b++)
{
Console.Write(student_details[a][b] + "\t");
}
for (int c = 0; c < SUBJECTS; c++)
{
for (int d = 0; d < 2; d++)
{
Console.Write(subject_details[c][d] + "\t");
}
}
}
}