From the course: Complete Guide to .NET LINQ: Querying Collections, Databases, and Markup

Unlock this course with a free trial

Join today to access over 24,700 courses taught by industry experts.

Challenge: Create a custom string output

Challenge: Create a custom string output

(gentle music) - [Instructor] It is time for your first code challenge. In this optional activity, I pose a small coding problem and you have the opportunity to create your own solution. The goal of this challenge is to write a link query that projects data into a custom anonymous type. The XML data that you will work with is in a file called webcolorsa.xml. You can find that here in the data folder, there it is. The contents of this file, there's a root element called web colors. Then there are a number of children elements. Here's an example, so this color element has two attributes, color name and color family, and it has several elements, hex, red, green, and blue, and hue, saturation and lightness. Your task is to retrieve the color name and to retrieve these three values. Then you're going to project out that information from your query. So here's what my solution looks like. Not the code, but what the solution looks like. So I created a type that has a color name, property, and…

Contents