From the course: .NET Essentials: LINQ for XML

Unlock the full course today

Join today to access over 22,500 courses taught by industry experts or purchase this course individually.

Solution: Filter results to show invalid values

Solution: Filter results to show invalid values - .NET Tutorial

From the course: .NET Essentials: LINQ for XML

Start my 1-month free trial

Solution: Filter results to show invalid values

(upbeat music) - [Narrator] I'd like to show you my solution. Remember your solution may be different from mine. I decided to use the C sharp program approach. So I have this main method, and then I have this IsValidHex method that returns a boolean. And I'm using a call to this IsValidHex here in my query. So I'm starting out getting all the elements. And then I'm calling IsValidHex and that's making this call here and I'm starting the Boolean results here is valid. And then I say, I have a where clause we'll skip this part of the where clause at the moment I say, where IsValid is equal to false. So this will show me non-valid hexadecimal values. And then I select out the results and I do an orderby is valid. And the solution I came up for solving this was to take the imp class and called TryParse, and I take my candidate string. And then one of the things you can pass in as TryParse is this number styles for…

Contents