Problems
Use the following problems to test your skills at working with advanced C# language features. Give each problem a try before you turn to the solutions and download the example programs.
Â
Â
38. Directory size, LINQ style
Repeat Problem 30. Directory size. This time, add a SizeLINQ
extension method to the DirectoryInfo
class that uses LINQ to calculate the size of the files inside the directory.
39. Directory size, PLINQ style
Repeat Problem 39. Directory size, LINQ style, but this time use PLINQ to add file lengths in parallel. Make the test program perform the same operations using a foreach
loop, LINQ, and PLINQ, and display the elapsed time for each. Let the user enter a number of times to repeat each operation so that you can get some meaningful times.
Note
Repeating each operation multiple times limits the time used by disk accesses because the file information should be cached after the first set of calculations.
40. Find files, LINQ style
Repeat Problem 34. Find files. This time, give...