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.

Solution: Create a custom string output

Solution: Create a custom string output

(casual uplifting music) - [Instructor] I hope you enjoyed tackling the challenge and experimenting with your own solution. Now, let's take a look at how I approached it. Keep in mind, your code might look different than mine, and that's okay. There are many valid ways to solve this kind of problem. You'll find my version in the Code Challenges folder here. It's called Solution A. So I started out by loading the file, and then getting all of the color elements, and then I'm doing a select New, and I'm creating two properties, the color name property and the formula property. The color name value is coming from the color attribute value, and my formula is I'm using an interpolated string here where I say, here's the RGB and the open paren, and then go get the element named reds value, same for the green value, and then the blue value, and then close the parentheses, and there's my results. If your solution is a little different, that's great. What matters most is that you're practicing…

Contents