LINQ is still used today

Chapter 8: LINQ

Practice creates masters

You can purchase the solutions to all of the exercises in this book as a ZIP file.

  1. Change your solution to exercise 4 from Section 6.6, "Tasks" so that a Favorites menu appears in the menu bar that contains the three menu items Add, Sort in ascending order and Sort in descending order. While the currently visible website is to be saved in the favorites manager when you click on Add, the favorites are to be sorted by name when you click on the other two menu items.

    For example, add two methods and to the class that you call in the event handlers for the menu items for sorting the favorites. Create appropriate LINQ queries that sort the favorites.

  2. Add a menu item Hide favorites on other servers to the Favorites menu that you developed in your solution for Task 1. This should hide all favorites that point to servers other than the server from which the currently visible website originates. If, for example, favorites for websites on and are saved in the favorites manager and a website from is currently visible, only the favorites belonging to this server should be displayed. All favorites should be able to be shown again via a menu item Show all favorites.

    You can proceed as in your solution to task 1. For example, expand the Favorites Manager by two methods by which the favorites can be shown and hidden.

  3. The status bar should show how many groups of favorites are currently saved. Favorites that point to websites on the same server should each form a group.

    To update the display in the status bar when the number of groups changes, you can, for example, add a new event property to the favorites manager. The Windows Forms application can then bind a method to this Event property and in this way can be informed when the number of groups changes.