Object Oriented Programming using C#

(backadmin) #1

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


However a much better choice for this collection would be to store the collection of accounts as a set, because sets do
not allow duplicates to be created.


Consider a set of bank accounts :-


Now consider two bank accounts one for Mr Smith and one for Mrs Jones. To be certain that no two accounts are duplicates
we would give each a unique account number – and we will do so later. For now we will assume that no two customers
born on the same day will have the same name.


It should not be possible to create a second account where the account holder has the same name and DOB as a previous
account holder. However unless told otherwise C# will treat the two objects below as different objects as both objects
have different names (Account1 and Account2) and thus while sets do not allow duplicates objects both of these accounts
could be created and added to a set because the computer does not recognize them as duplicates..

Free download pdf