About This eBook
ePUB is an open, industry-standard format for eBooks. However, support of ePUB and its many features varies across reading devices and applications. Use your device or app settings to customize the presentation to your liking. Settings that you can customize often include font, font size, single or double column, landscape or portrait mode, and figures that you can click or tap to enlarge. For additional information about the settings and features on your reading device or app, visit the device manufacturers Web site.
Many titles include programming code or configuration examples. To optimize the presentation of these elements, view the eBook in single-column, landscape mode and adjust the font size to the smallest setting. In addition to presenting code and configurations in the reflowable text format, we have included images of the code that mimic the presentation found in the print book; therefore, where the reflowable format may compromise the presentation of the code listing, you will see a Click here to view code image link. Click the link to view the print-fidelity code image. To return to the previous page viewed, click the Back button on your device or app.
C# 5.0 Unleashed
Bart De Smet
800 East 96th Street, Indianapolis, Indiana 46240 USA
C# 5.0 Unleashed
Copyright 2013 by Pearson Education, Inc.
All rights reserved. No part of this book shall be reproduced, stored in a retrieval system, or transmitted by any means, electronic, mechanical, photocopying, recording, or otherwise, without written permission from the publisher. No patent liability is assumed with respect to the use of the information contained herein. Although every precaution has been taken in the preparation of this book, the publisher and author assume no responsibility for errors or omissions. Nor is any liability assumed for damages resulting from the use of the information contained herein.
ISBN-13: 978-0-672-33690-4
ISBN-10: 0-672-33690-1
Library of Congress Cataloging-in-Publication Data is on file.
Printed in the United States of America
First Printing: April 2013
Editor-in-Chief
Greg Wiegand
Acquisitions Editor
Neil Rowe
Development Editor
Mark Renfrow
Managing Editor
Kristy Hart
Project Editor
Andy Beaster
Copy Editor
Keith Cline
Indexer
Brad Herriman
Proofreader
Debbie Williams
Technical Editor
Christopher Wilcox
Editorial Assistant
Cindy Teeters
Cover Designer
Anne Jones
Compositor
Nonie Ratcliff
Trademarks
All terms mentioned in this book that are known be trademarks or service marks have been appropriately capitalized. Sams Publishing cannot attest to the accuracy of this information. Use of a term in this book should not be regarded as affecting the validity of any trademark or service mark.
Warning and Disclaimer
Every effort has been made to make this book as complete and as accurate as possible, but no warranty or fitness is implied. The information provided is on an as is basis. The authors and the publisher shall have neither liability nor responsibility to any person or entity with respect to any loss or damages arising from the information contained in this book.
Bulk Sales
Sams Publishing offers excellent discounts on this book when ordered in quantity for bulk purchases or special sales. For more information, please contact
U.S. Corporate and Government Sales
1-800-382-3419
For sales outside of the U.S., please contact
International Sales
Contents at a Glance
Table of Contents
About the Author
Bart J.F. De Smet is a software development engineer on Microsofts Cloud Programmability Team, an avid blogger, and a popular speaker at various international conferences. In his current role, hes actively involved in the design and implementation of Reactive Extensions for .NET (Rx) and on an extended LINQ to Anything mission. You can read about Barts technical adventures on his blog at http://blogs.bartdesmet.net/bart.
His main interests include programming languages, virtual machines and runtimes, functional programming, and all sorts of theoretical foundations. In his spare time, Bart likes to go out for a hike in the wonderful nature around Seattle, read technical books, and catch up on his game of snooker.
Before joining the company in October 2007, Bart was active in the .NET community as a Microsoft Most Valuable Professional (MVP) for C#, while completing his Bachelor of Informatics, Master of Informatics, and Master of Computer Science Engineering studies at Ghent University, Belgium.
Acknowledgments
Writing this book was a huge undertaking that would have proven impossible without the support of many people. Id like to apologize upfront for forgetting any of you. (Ill buy you a Belgian beer if I did.)
First and foremost, I cannot thank my family enough for the support theyve given me over the years to pursue my dreams. Their support for my 6-year university studies in Ghent and tolerance for my regular absence to participate in the technical community have all been essential ingredients. If this werent enough, my move across the Pacific Ocean to go and work at the Microsoft headquarters has put us through the ultimate test. Words fall short to describe how incredibly lucky I am to have their ongoing support. Thanks once more!
I wouldnt have ended up in the world of computer science if not for some of my teachers. For my first exposure to computers, I have to go back to 1993, checking sums during the mathematics lessons at elementary school. Thanks to Meester Wilfried for his MS-DOS and GWBASIC powered calculator that shaped my future. In high school, several people kept me on this track, as well. Math teachers Paul, Geert, and Ronny had to endure endless conversations about programming languages. In a weird twist of history, I never got educated in informatics in high school, but nonetheless I spent countless hours in the computer rooms of my school. Without the support of Hans De Four, I wouldnt have gotten where I am today. Sorry for all the network downtime caused by my continuous experiments with ProfPass, domain controllers, and whatnot.
Looking back over 10 years in history, Im eternally grateful to the people at the local Microsoft subsidiary in Belgium (back then called Benelux) for adopting me in the early .NET community and giving me the chance to work on various projects. In particular, I want to thank my very first contact at Microsoft, Gunther Beersaerts, for all the advice he gave me over the years. Gunthers been a true source of inspiration, encouraging me to take the speaker stand at various conferences.
During a few summers in the early 2000s, many Microsoft Belgium people provided a nice place for me to grow and learn while working on various exciting projects. Thanks to Chris Volckerick for taking me on board to build the (now defunct) http://www.dotnet.be website, using what was called ASP+ back then. Later, Gerd De Bruycker took me under his wing to develop the first MSDN home page for Microsoft Belux. Your passion for the developer community has always stuck with me (not just that wild community VIP party in Knokke).
A bigger project called SchoolServer came around in the summer of 2004 and lasted for the years after. Christian Ramiouls faith in my technical skills needed to land this project was unbelievable. And getting to know the IT professional audience that had to work with the solution wouldnt have been possible without the wonderful collaboration I had with Ritchie Houtmeyers (remember the countless hours spent in our server room office?) and Ricardo Noulez. Big thanks go to Bart Vande Ghinste for giving me a crash course on COM+.