Exercise: Practice in converting C# variable types

This exercise is provided to allow potential course delegates to choose the correct Wise Owl Microsoft training course, and may not be reproduced in whole or in part in any format without the prior written consent of Wise Owl.

The answer to the exercise will be included and explained if you attend one of more of the courses listed below!

Category ==> Visual C Sharp  (65 exercises)
Topic ==> C# variables  (4 exercises)
Level ==> Average difficulty
Courses ==> Introduction to Visual C#  /  WinForms using Visual C#

You need a minimum screen resolution of about 700 pixels width to see our exercises. This is because they contain diagrams and tables which would not be viewable easily on a mobile phone or small laptop. Please use a larger tablet, notebook or desktop computer, or change your screen resolution settings.

The idea behind this exercise is to create a dating agency application form (we'll call it frmMoneySpent).  The agency only collects two bits of information per applicant: the person's name, and the amount of money they require to be spent on them on their date:

Visual C Sharp 2010 exercise - C# variables (image 1)

£2,000 a date puts Bob in the high-class escort category

The dating agency imposes a ceiling of £100 per date.  Attach code to the OK button to display a suitable error message if an applicant gets too greedy:

Visual C Sharp 2010 exercise - C# variables (image 2)

Check that the amount entered is a number, then compare this with the £100 limit

On the other hand, your event-handling code should display a nice reassuring message if the amount entered is within limits:

Visual C Sharp 2010 exercise - C# variables (image 3)

The message should include the person's name

Try out the various scenarios (invalid amount, too much, etc.) to check everything works, then close down your form.

This page has 0 threads Add post