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: Filter results for invalid values

Solution: Filter results for invalid values

(upbeat music) - [Instructor] I hope you enjoyed working on this challenge. Here is how I solved the problem. First of all, let's look at my answers. So I found two elements that match my criteria. One is this color named Indigo, which has an invalid character, the letter H in the Hex. The second one is this color Mint.Cream, which has this period in the middle of the word. So the way I wrote this query is I started off by getting the webColors. And then I am making a call to this method called IsValidHex. So I wrote a variable here called isValid and I'm getting the Hex elements value, and then I'm passing that in to this method. We'll talk about the code here in a minute. Then I write a where clause where I say check for the color-name value contains a period, or this variable isValid == false. And then I orderby isValid and then I select out the results. This is one of the interesting parts of this query is how do you solve this IsValidHex. And the way I did it is by using…

Contents