C
C#•2y ago
k.illua

Desktop Information System

I need help with my code as I get an error every time it tries to output the student data.
8 Replies
k.illua
k.illuaOP•2y ago
Here is the code
k.illua
k.illuaOP•2y ago
k.illua
k.illuaOP•2y ago
The delete option won't work properly either, it won't display any of the existing data
Angius
Angius•2y ago
What's the error and where does it happen? As a side note, writing
private int _foo = 0;
public int Foo {
get { return _foo }
set { _foo = value }
}
private int _foo = 0;
public int Foo {
get { return _foo }
set { _foo = value }
}
is just writing useless boilerplate code, it can be replaced by just
public int Foo { get; set; }
public int Foo { get; set; }
k.illua
k.illuaOP•2y ago
I am getting this error 'System.FormatException: 'Index (zero based) must be greater than or equal to zero and less than the size of the argument list.' On this line case Student student: Console.WriteLine("{0,-10} {1,-15} {2,-10} {3,-15} {4,-20} {5,-10} {6,-8} {7,-8} {8,-5} {9,-10} {10,-10} {11,-15} {12,-15}", recordNumber++, student.Name, student.Role, student.Telephone, student.Email, "-", "-", "-", student.Subject, student.Subject2, student.PrvSubject, student.PrvSubject2); break; Thank you for the tip, I'll adjust my classes
Angius
Angius•2y ago
You seem to have 13 slots in this string and 12 arguments That's why string interpolation is better
k.illua
k.illuaOP•2y ago
Thank you for the help 🙂 I have completed the code
Angius
Angius•2y ago
Nice
Want results from more Discord servers?
Add your server