Visual C# | Advanced LINQ exercise | Create an anonymous type in LINQ to show star signs

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 ==> Advanced LINQ  (2 exercises)
Level ==> Average difficulty
Subject ==> C# training
Before you can do this exercise, you'll need to download and unzip this file (if you have any problems doing this, click here for help).

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.

Add the files in the folder above into a new or existing project, and make the form frmStarSigns the default form.  When you run your project, you should see this:

Default form listing star signs

When you click on the button, you should see just a title for the listbox.


Write a LINQ expression to return an anonymous type for each star sign, containing the following two properties:

Property Notes
SignName This can use the existing class property - you don't need to rename it.
SignDate This can use the class's existing SignDate property.  You'll need to give this property a name when creating your anonymous type.

Iterate over the items in this LINQ expression, so that clicking on the button shows the following: 

Star signs with dates

When you click on the button, this is what you should see.


Aren't anonymous types the bees' knees?

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