Exercise: Calculate age bands using an enumeration

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 2010  (65 exercises)
Topic ==> Enumerations and constants  (2 exercises)
Level ==> Relatively easy
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 allow applicants to a dating agency to input their name and age.  The system will then suggest which club they should join!

To do this, first create a form called frmAgeCategory as follows:

Visual C Sharp 2010 exercise - Enumerations and constants (image 1)

One of the older applicants ...

Create an event-handler for the button to show a different message according to the applicant's age.  Here's what part of your code could look like (you'll need to write the enumeration AgeBand too to get this to work):

Visual C Sharp 2010 exercise - Enumerations and constants (image 2)

The indentation helps understand the various conditions

When everything is working OK, close down your form.

This page has 0 threads Add post