Object Oriented Programming using C#

(backadmin) #1

Object Oriented Programming using C#
Generic Collections and how to Serialize them


Activity 2

For each of the following problems write down which would be most appropriate :- a list, a set or a dictionary.

1) We want to record the members of a club.
2) We want to keep a record of the money we spend (and what it was spent on).
3) We want to record bank account details – each identified by a bank account number

Feedback 2

1) For this we would use a Set. Members can be added and removed as required and the members are in
no particular order.
2) For this we would use a List – this would record the items bought in the order in which they were
purchased. Importantly as lists allows duplicate items we could buy two identical toys (perhaps for
birthday presents for two different children),
3) We would not have two identical Bank accounts so a Set seems appropriate however as each is identified
by a unique account number a Dictionary would be the most appropriate choice.
Free download pdf