Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

C#: one to many relation data type

Tags:

c#

dictionary

For one-to-one I can use Hash or dictionary. Forexample Smith is 26 years old, Brown is 35 years old. This is clear. What about one to many? Forexample Smith is attending class01, class08, class12 and Brown is attending class01, class05, and class08. What are my alternatives and what is the best choice?

like image 968
John Ryann Avatar asked Dec 06 '22 12:12

John Ryann


1 Answers

You can still use a Dictionary, but you need to make the value type a collection, ie: Dictionary<Person, IList<Class>>. This would allow you to store a list of classes per person.

like image 60
Reed Copsey Avatar answered Dec 10 '22 02:12

Reed Copsey