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
From the course: Complete Guide to .NET LINQ: Querying Collections, Databases, and Markup
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
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
(Locked)
Use Query syntax to work with elements4m 59s
-
(Locked)
Query element values in XML1m 10s
-
(Locked)
Query attributes in XML1m 56s
-
(Locked)
Project data into an anonymous type4m 10s
-
(Locked)
Filter by attribute value with Where1m 52s
-
(Locked)
Use Where to compare values2m 10s
-
(Locked)
Perform aggregate queries in XML1m 26s
-
(Locked)
Sort query results with OrderBy3m 29s
-
(Locked)
Find empty elements and blank values4m 51s
-
(Locked)
Group XML data with GroupBy3m 48s
-
(Locked)
Challenge: Create a custom string output1m 50s
-
(Locked)
Solution: Create a custom string output1m 19s
-
(Locked)
Challenge: Filter elements with no content52s
-
(Locked)
Solution: Filter elements with no content51s
-
(Locked)
Challenge: Filter results for invalid values1m 28s
-
(Locked)
Solution: Filter results for invalid values1m 54s
-
(Locked)
-
-