Visual C# | Enumerations and constants 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.

Software ==> Visual C#  (79 exercises)
Version ==> Any version of C#
Topic ==> Enumerations and constants  (2 exercises)
Level ==> Relatively easy
Subject ==> C# training

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.

You can unzip this file to see the answers to this exercise, although please remember this is for your personal use only.
This page has 0 threads Add post