The Modern C# Challenge

Book description

Learn advanced C# concepts and techniques such as building caches, cryptography, and parallel programming by solving interesting programming challenges

Key Features

  • Gain useful insights on advanced C# programming topics and APIs
  • Use locking and cached values to solve parallel problems
  • Take advantage of .NET's cryptographic tools to encrypt and decrypt strings

Book Description

C# is a multi-paradigm programming language. The Modern C# Challenge covers with aspects of the .NET Framework such as the Task Parallel Library (TPL) and CryptoAPI. It also encourages you to explore important programming trade-offs such as time versus space or simplicity. There may be many ways to solve a problem and there is often no single right way, but some solutions are definitely better than others. This book has combined these solutions to help you solve real-world problems with C#.

In addition to describing programming trade-offs, The Modern C# Challenge will help you build a useful toolkit of techniques such as value caching, statistical analysis, and geometric algorithms.

By the end of this book, you will have walked through challenges in C# and explored the .NET Framework in order to develop program logic for real-world applications.

What you will learn

  • Perform statistical calculations such as finding the standard deviation
  • Find combinations and permutations
  • Search directories for files matching patterns using LINQ and PLINQ
  • Find areas of polygons using geometric operations
  • Randomize arrays and lists with extension methods
  • Explore the filesystem to find duplicate files
  • Simulate complex systems and implement equality in a class
  • Use cryptographic techniques to encrypt and decrypt strings and files

Who this book is for

The Modern C# Challenge is for all C# developers of different abilities wanting to solve real-world problems. There are problems for everyone at any level of expertise in C#

Table of contents

  1. Title Page
  2. Copyright and Credits
    1. The Modern C# Challenge
  3. Dedication
  4. Packt Upsell
    1. Why subscribe?
    2. Packt.com
  5. Contributors
    1. About the author
    2. About the reviewer
    3. Packt is searching for authors like you
  6. Preface
    1. Who this book is for
    2. What this book covers
    3. To get the most out of this book
      1. Download the example code files
      2. Download the color images
      3. Conventions used
    4. Get in touch
      1. Reviews
  7. Mathematics
    1. Problems
      1. 1. Statistical functions
      2. 2. Permutations
      3. 3. Combinations
      4. 4. Factorials
      5. 5. Fibonacci numbers
      6. 6. Binomial coefficients
      7. 7. Pascal's triangle
      8. 8. Greatest common divisors
      9. 9. Least common multiples
      10. 10. Sums of multiples
      11. 11. Primality testing
      12. 12. Prime table
      13. 13. Prime factors
      14. 14. Unique prime factors
      15. 15. Prime tuples
      16. 16. Proper divisors
      17. 17. Amicable numbers
      18. 18. Perfect numbers
      19. 19. Armstrong numbers
    2. Solutions
      1. 1. Statistical functions
      2. 2. Permutations
      3. 3. Combinations
      4. 4. Factorials
      5. 5. Fibonacci numbers
      6. 6. Binomial coefficients
      7. 7. Pascal's triangle
      8. 8. Greatest common divisors
      9. 9. Least common multiples
      10. 10. Sums of multiples
      11. 11. Primality testing
      12. 12. Prime table
      13. 13. Prime factors
      14. 14. Unique prime factors
      15. 15. Prime tuples
      16. 16. Proper divisors
      17. 17. Amicable numbers
      18. 18. Perfect numbers
      19. 19. Armstrong numbers
  8. Geometry
    1. Problems
      1. 20. Monte Carlo π
      2. 21. Newton's π
      3. 22. Bisection root-finding
      4. 23. Newton's method
      5. 24. Gaussian elimination
      6. 25. Monte Carlo integration
      7. 26. Rectangle rule integration
      8. 27. Trapezoid rule integration
      9. 28. Arrowheads
      10. 29. Line-line intersection
      11. 30. Point-line distance
      12. 31. Point-segment distance
      13. 32. Segment-segment distance
      14. 33. Circle selection
      15. 34. Line-circle intersection
      16. 35. Circle-circle intersection
      17. 36. Circle-line tangents
      18. 37. Polygon area
      19. 38. Point in a polygon
      20. 39. Convexity testing
      21. 40. Stars
    2. Solutions
      1. 20. Monte Carlo π
      2. 21. Newton's π
      3. 22. Bisection root-finding
      4. 23. Newton's method
      5. 24. Gaussian elimination
      6. 25. Monte Carlo integration
      7. 26. Rectangle rule integration
      8. 27. Trapezoid rule integration
      9. 28. Arrowheads
      10. 29. Line-line intersection
      11. 30. Point-line distance
      12. 31. Point-segment distance
      13. 32. Segment-segment distance
      14. 33. Circle selection
      15. 34. Line-circle intersection
      16. 35. Circle-circle intersection
      17. 36. Circle-line tangents
      18. 37. Polygon area
      19. 38. Point in a polygon
      20. 39. Convexity testing
      21. 40. Stars
  9. Dates and Times
    1. Problems
      1. 41. Days of the week
      2. 42. Date and time picker
      3. 43. Time zone chart
      4. 44. Scheduling meetings
      5. 45. Time zone clocks
      6. 46. Local time zone clocks
      7. 47. Calculating duration
      8. 48. Calculating age
    2. Solutions
      1. 41. Days of the week
      2. 42. Date and time picker
      3. 43. Time zone chart
      4. 44. Scheduling meetings
      5. 45. Time zone clocks
      6. 46. Local time zone clocks
      7. 47. Calculating duration
      8. 48. Calculating age
  10. Randomization
    1. Problems
      1. 49. Random doubles
      2. 50. Random items
      3. 51. Randomize items
      4. 52. Random groups
      5. 53. Choose items with probabilities
      6. 54. Random passwords
      7. 55. Random walks
    2. Solutions
      1. 49. Random doubles
      2. 50. Random items
      3. 51. Randomize items
      4. 52. Random groups
      5. 53. Choose items with probabilities
      6. 54. Random passwords
      7. 55. Random walks
  11. Strings
    1. Problems
      1. 56. Roman numerals
      2. 57. Bytes to hex
      3. 58. Removing punctuation
      4. 59. Palindromic substrings
      5. 60. Validating passwords
      6. 61. Edit distance
      7. 62. Soundex
      8. 63. Longest common substring
    2. Solutions
      1. 56. Roman numerals
      2. 57. Bytes to hex
      3. 58. Removing punctuation
      4. 59. Palindromic substrings
      5. 60. Validating passwords
      6. 61. Edit distance
      7. 62. Soundex
      8. 63. Longest common substring
  12. Files and Directories
    1. Problems
      1. 64. Removing blank lines
      2. 65. Directory size
      3. 66. Finding duplicate files
      4. 67. Thumbnails
      5. 68. Thumbnail web page
      6. 69. Find files
      7. 70. Find and Replace
      8. 71. Saving images
      9. 72. Compressing images
    2. Solutions
      1. 64. Removing blank lines
      2. 65. Directory size
      3. 66. Finding duplicate files
      4. 67. Thumbnails
      5. 68. Thumbnail web page
      6. 69. Find files
      7. 70. Find and Replace
      8. 71. Saving images
      9. 72. Compressing images
  13. Advanced C# and .NET Features
    1. Problems
      1. 73. Directory size, LINQ style
      2. 74. Directory size, PLINQ style
      3. 75. Find files, LINQ style
      4. 76. Parallel primes table
      5. 77. Parallel prime tuples
      6. 78. Parallel Monte Carlo π
      7. 79. Yielding primes
      8. 80. Yielding Fibonacci numbers
      9. 81. Complex numbers
    2. Solutions
      1. 73. Directory size, LINQ style
      2. 74. Directory size, PLINQ style
      3. 75. Find files, LINQ style
      4. 76. Parallel primes table
      5. 77. Parallel primes tuple
      6. 78. Parallel Monte Carlo π
      7. 79. Yielding primes
      8. 80. Yielding Fibonacci numbers
      9. 81. Complex numbers
  14. Simulations
    1. Problems
      1. 82. Dawkins' weasel
      2. 83. Hailstone sequence
      3. 84. Hailstone sequence, Redux
      4. 85. Langton's Ant
      5. 86. Life
      6. 87. Sharks and Fish
      7. 88. Slingshot
      8. 89. Slingshot refinements
      9. 90. Space Force
    2. Solutions
      1. 82. Dawkins' weasel
      2. 83. Hailstone sequence
      3. 84. Hailstone Sequence, Redux
      4. 85. Langton's Ant
      5. 86. Life
      6. 87. Sharks and Fish
      7. 88. Slingshot
        1. Projectile motion
        2. Example solution
      8. 89. Slingshot refinements
      9. 90. Space Force
        1. Sprite classes
        2. Bubble
        3. Ship
        4. Keyboard events
        5. Other details
  15. Cryptography
    1. Problems
      1. 91. Caesar cipher
      2. 92. Vigenère cipher
      3. 93. Cryptographic pseudorandom numbers
      4. 94. Primality testing, redux
      5. 95. Find primes
      6. 96. Hash files
      7. 97. Steganography
      8. 98. Encrypt and decrypt strings
      9. 99. Encrypt and decrypt files
      10. 100. CryptoPad
    2. Solutions
      1. 91. Caesar cipher
      2. 92. Vigenère cipher
      3. 93. Cryptographic random numbers
      4. 94. Primality testing, redux
      5. 95. Find primes
      6. 96. Hash files
      7. 97. Steganography
      8. 98. Encrypt and decrypt strings
      9. 99. Encrypt and decrypt files
      10. 100. CryptoPad
  16. Other Books You May Enjoy
    1. Leave a review - let other readers know what you think

Product information

  • Title: The Modern C# Challenge
  • Author(s): Rod Stephens
  • Release date: October 2018
  • Publisher(s): Packt Publishing
  • ISBN: 9781789535426