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 - .NET Tutorial
From the course: .NET Essentials: LINQ for XML
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
-
-
-
-
-
Use Query syntax to work with elements2m 46s
-
Attribute query1m 27s
-
Select data into a new anonymous type1m 47s
-
Where clause on attribute value1m 53s
-
Where clause with compare2m 11s
-
Aggregate queries2m 1s
-
Choose output order with OrderBy42s
-
Query for empty elements and blank values3m 21s
-
Group by3m 26s
-
Challenge: Create custom string output1m 46s
-
Solution: Create custom string output1m 14s
-
Challenge: Filter results to show elements with no content47s
-
Solution: Filter results to show elements with no content55s
-
Challenge: Filter results to show invalid values1m 39s
-
Solution: Filter results to show invalid values1m 53s
-
-
-