Object Oriented Programming using C#

(backadmin) #1
Object Oriented Programming using C#
Case Study

The ApplicationWindow_Load() method reconstructs any previously stored ClientBook and MessageSet objects.

The action listener for the SaveAndExit button is shown below....

private void btnSaveAndExit_Click(object sender, EventArgs e)
{
FileStream outFile = new FileStream(“ClientAndMessageData”,
FileMode.Create, FileAccess.Write);
BinaryFormatter bFormatter = new BinaryFormatter();

bFormatter.Serialize(outFile, clientBook);
bFormatter.Serialize(outFile, messageSet);
outFile.Close();
outFile.Dispose();
this.Close();
}

Note how with just four lines of code above we can create an appropriate output stream and save all client book and message
set data – this includes details of all clients and all messages. While we had to mark the relevant classes, ClientBook, Client,
MessageSet and Message, as serializable we did not have to write any code to save this data to file.

What do you want to do?


No matter what you want out of your future
career, an employer with a broad range of
operations in a load of countries will always
be the ticket. Working within the Volvo Group
means more than 100,000 friends and
colleagues in more than 185 countries all
over the world. We offer graduates great
career opportunities – check out the Career
section at our web site http://www.volvogroup.com.
We look forward to getting to know you!

AB Volvo (publ)www.volvogroup.com

VOLVO TRUCKS I RENAULT TRUCKS I MACK TRUCKS I VOLVO BUSES I VOLVO CONSTRUCTION EQUIPMENT I VOLVO PENTA I VOLVO AERO I VOLVO IT
VOLVO FINANCIAL SERVICES I VOLVO 3P I VOLVO POWERTRAIN I VOLVO PARTS I VOLVO TECHNOLOGY I VOLVO LOGISTICS I BUSINESS AREA ASIA

Please click the advert

Free download pdf