I'm teaching myself how to use classes in c#. I have a 'what's the best way' question I'm hoping someone with experience can give me guidance on.
Say I have a class object for a 'Teacher'. The class has members for the teacher's name, grade level, pay rate, and so on. I'd also like to store a variable-length list of properties for him. If he has various roles for different courses, like this:
English 1A | Instructor
English Lit | Advisor
Beginning Math | Substitute
Study Hall | Monitor
English 6b | Instructor
I'd like to store this information in his class object, and be able to access it in my code. I've tried an ArrayList, a HashTable, and a List<> (which doesn't let me store multiple columns, I don't think), but my approaches all feel like clunky workarounds. I'm leaning toward doing it this way:
This guy suggests creating a class object with two members and storing new instances of the class in a list. Good idea, but again, it has a 'workaround' feel to it.
Is there one "Right" way to do what I'm trying to do? Or can somebody suggest a more direct approach? Any thoughts are appreciated.