0

I have a Student class that creates an object: This is the constructor

public Student(string StudentID, string Name, string Status, Enum StudentMajor, string[][] CompletedCourses)

You can see that the field CompletedCourses is a jagged array, the idea is that it stores the course that the student has completed and the grade(s) they received in the course.

This is how I created the object in the main class but I don't think it's done correctly:

Student student = new("00069110", "Haaland", "Full-time", Majors.Computer_Information_Systems,
new string[][]//What's the correct to populate this jagged array
{
    //Here the course is supposed to be in an array and "A"(the grade) is supposed to be in another array
    new string[] {"ITEC_120_Introduction_to_Computer_Hardware", "A"}
});
stuartd
  • 70,509
  • 14
  • 132
  • 163
NewDev
  • 27
  • 7
  • 7
    As an aside, this seems like a pretty poor design. A `record CompletedCourse(string Name, string Grade)` would not go amiss. Arrays like this (whether jagged or multidimensional) tend to be unfriendly for anything other than numerical applications. – Jeroen Mostert Oct 13 '22 at 20:48
  • 1
    `new string[][] { new[] { "course" }, new[] { "grade" } }`? I'm not so sure a jagged array is what you should be using though. Did you consider using a dictionary instead? – 41686d6564 stands w. Palestine Oct 13 '22 at 20:48
  • @ 41686d6564 stands w. Palestine I don't think a dictionary is the appropriate collection to use in this case. – NewDev Oct 14 '22 at 02:39

0 Answers0