The Modern C# Challenge
Become an expert C# programmer by solving interesting programming problems
Rod Stephens
BIRMINGHAM - MUMBAI
The Modern C# Challenge
Copyright 2018 Packt Publishing
All rights reserved. No part of this book may be reproduced, stored in a retrieval system, or transmitted in any form or by any means, without the prior written permission of the publisher, except in the case of brief quotations embedded in critical articles or reviews.
Every effort has been made in the preparation of this book to ensure the accuracy of the information presented. However, the information contained in this book is sold without warranty, either express or implied. Neither the author, nor Packt Publishing or its dealers and distributors, will be held liable for any damages caused or alleged to have been caused directly or indirectly by this book.
Packt Publishing has endeavored to provide trademark information about all of the companies and products mentioned in this book by the appropriate use of capitals. However, Packt Publishing cannot guarantee the accuracy of this information.
Commissioning Editor: Pavan Ramchandani
Acquisition Editor: Sandeep Mishra
Content Development Editor: Akshada Iyer
Technical Editor: Adhithya Haridas
Copy Editor: Safis Editing
Project Coordinator: Prajakta Naik
Proofreader: Safis Editing
Indexer: Aishwarya Gangawane
Graphics: Jisha Chirayil
Production Coordinator: Shraddha Falebhai
First published: October 2018
Production reference: 2021118
Published by Packt Publishing Ltd.
Livery Place
35 Livery Street
Birmingham
B3 2PB, UK.
ISBN 978-1-78953-542-6
www.packt.com
For Amy and Ken
mapt.io
Mapt is an online digital library that gives you full access to over 5,000 books and videos, as well as industry leading tools to help you plan your personal development and advance your career. For more information, please visit our website.
Why subscribe?
Spend less time learning and more time coding with practical eBooks and Videos from over 4,000 industry professionals
Improve your learning with Skill Plans built especially for you
Get a free eBook or video every month
Mapt is fully searchable
Copy and paste, print, and bookmark content
Packt.com
Did you know that Packt offers eBook versions of every book published, with PDF and ePub files available? You can upgrade to the eBook version at www.packt.com and as a print book customer, you are entitled to a discount on the eBook copy. Get in touch with us at customercare@packtpub.com for more details.
At www.packt.com , you can also read a collection of free technical articles, sign up for a range of free newsletters, and receive exclusive discounts and offers on Packt books and eBooks.
Contributors
About the author
Rod Stephens has been a software developer, consultant, instructor, and author. He has written more than 30 books and 250 magazine articles covering such topics as three-dimensional graphics, algorithms, database design, software engineering, interview puzzles, C#, and Visual Basic.
Rod's popular C# Helper and VB Helper websites receive millions of hits per year and contain thousands of tips, tricks, and example programs for C# and Visual Basic developers. Some of his most recent books include:
- WPF 3d : Three-Dimensional Graphics with WPF and C#
- Interview Puzzles Dissected: Solving and Understanding Interview Puzzles
- Beginning Software Engineering
- Essential Algorithms: A Practical Approach to Computer Algorithms
Thanks to Sandeep Mishra, Akshada Iyer, and Adhithya Haridas for helping me put this book together.
About the reviewer
Luis Felipe is a software developer with a degree in software analysis and development, and he is studying for a specialization in software engineering. The main technologies he works with are ASP.NET Core, Angular (2+), SQL Server databases and MongoDB. He has been studying the C# language for almost 10 years and has passed the Microsoft 70-483 certification exam Programming with C#.
He currently works for the public ministry, working with the developing team to build the most important software for the institution of the last years. He also worked as a freelance developer, working on desktop and web applications using C#.
I really must start thanking my mother Luiza, my sister Ingrid and my girlfriend Helora. They were important in helping me to get the reviewing process done, by supporting me. My father, who passed away last year, always motivated me a lot to study and work hard.
I thank him a lot. Also, I must thank the publishing team, who helped me a lot in learning the reviewing process to improve the book quality.
Packt is searching for authors like you
If you're interested in becoming an author for Packt, please visit authors.packtpub.com and apply today. We have worked with thousands of developers and tech professionals, just like you, to help them share their insight with the global tech community. You can make a general application, apply for a specific hot topic that we are recruiting an author for, or submit your own idea.
Preface
So you've read an introductory book and perhaps one or two more advanced books. You've worked with C# for a while and now you're ready for something that wasn't written for idiots or dummies. This book may be just the thing!
This book includes 100 problems (with solutions) that you can use to test and hone your C# programming skills. They cover an eclectic assortment of topics, such as mathematical calculations, geometry, dates and times, the filesystem, simulations, and cryptography. These problems won't make you an expert in those fields, but they will give you some experience with a wide variety of useful topics.
As with many skills, the best way to learn programming is to practice. Most programming books cover roughly the same topics, so they don't give you the opportunity to practice skills that fall into the programming nooks and crannies that those books miss. They do a good job of covering basic topics, such as forms, controls, classes, and for loops. More advanced books also cover more specialized topics, such as algorithms (I've written a few algorithms books), databases, web programming, and phone apps. Few books have room for more specialized topics, such as mathematical calculations, simulations, and cryptography. You'll get a brief introduction to those topics here.
In addition to giving you practice with some of programming's less heavily-trodden byways, many of the examples in this book demonstrate important C# programming concepts. They show how to protect your programs from integer and floating point overflow, avoid exhausting stack memory, know when LINQ or PLINQ might hurt performance, handle times in multiple time zones, and use the yield statement.
Next page