ebook img

C# 2010 All-in-One For Dummies: 8 Books in 1 PDF

867 Pages·2010·13.483 MB·English
Save to my drive
Quick download
Download
Most books are stored in the elastic cloud where traffic is expensive. For this reason, we have a limit on daily download.

Preview C# 2010 All-in-One For Dummies: 8 Books in 1

spine=1.73” Experience the fun and power Web/Page Design C# 4.0 DevelopmentService Oriented Web Programming ProgrammingWindows Studio®A Tour of Visual Designing for C# Object Oriented C# ProgrammingBasics of C# Making Everything Easier!™ as you learn to write your 0 1 0 own C# applications 2 Open the book and find: C # What are you going to create with C#? Maybe your first (cid:129) Steps for creating your first C# Windows® 7 application? Or how about digging into Web console application C construction? With this comprehensive book, you’ll be (cid:129) How to take advantage of object- able to decide where you want to go next. It takes you oriented programming A # tsherroviucgehs deevveerylothpimnge nfrto smo yVoisuu caal nSt sutdairot banudild WinPgF y toou Wr oewb na nd (cid:129) Techniques for writing secure LL A L L - I N - O N E code - applications. 2 I (cid:129) Tips on how to use Visual Studio N (cid:129) Dig into C# — dive into object-oriented programming to create and create macros -0 good class libraries (cid:129) Ways to implement Web services O (cid:129) Make it secure — learn how to identify risks and then build with SOAP N1 Windows and Web applications with the right security (cid:129) How to build Web applications E 0 (cid:129) Jump into .NET — from coding for Windows Mobile to accessing and leverage the Framework XML files, you’ll uncover what you can do with the .NET (cid:129) Where you can take your framework applications with dynamic (cid:129) Develop with WPF — discover key WPF concepts as well as programming common application patterns used in the software industry today 8 (cid:129) Get Visual — find out how to use, optimize, and customize Visual BBOOOOKKSS Studio’s graphic user interface 1 IN Go to Dummies.com ® Visit the companion Web site at www.csharpfordummies. for videos, step-by-step examples, how-to articles, or to shop! net to find the source code for all the projects in the book, (cid:129) Basics of C# Programming updated for Visual Studio 2010 (cid:129) Object Oriented C# (cid:129) Designing for C# (cid:129) A Tour of Visual Studio® (cid:129) Windows Programming (cid:129) Web Programming $39.99 US / $47.99 CN / £27.99 UK (cid:129) Service Oriented Development Bill Sempf is a seasoned programmer and .NET evangelist specializing ISBN 978-0-470-56348-9 (cid:129) C# 4.0 in .NET applications. Chuck Sphar is a programmer and former senior Bill Sempf technical writer for the Visual C++ product group at Microsoft. Stephen Randy Davis is the bestselling author of several books, including C++ Sempf Chuck Sphar For Dummies. Sphar Stephen Randy Davis Davis spine=1.73” Get More and Do More at Dummies.com ® Start with FREE Cheat Sheets Cheat Sheets include (cid:129) Checklists (cid:129) Charts (cid:129) Common Instructions (cid:129) And Other Good Stuff! To access the Cheat Sheet created specifically for this book, go to www.dummies.com/cheatsheet/csharp2010aio Get Smart at Dummies.com Dummies.com makes your life easier with 1,000s of answers on everything from removing wallpaper to using the latest version of Windows. Check out our (cid:129) Videos (cid:129) Illustrated Articles (cid:129) Step-by-Step Instructions Plus, each month you can win valuable prizes by entering our Dummies.com sweepstakes. * Want a weekly dose of Dummies? Sign up for Newsletters on (cid:129) Digital Photography (cid:129) Microsoft Windows & Office (cid:129) Personal Finance & Investing (cid:129) Health & Wellness (cid:129) Computing, iPods & Cell Phones (cid:129) eBay (cid:129) Internet (cid:129) Food, Home & Garden Find out “HOW” at Dummies.com *Sweepstakes not currently available in all countries; visit Dummies.com for official rules. C# 2010 ALL-IN-ONE FOR DUMmIES ‰ by Bill Sempf, Chuck Sphar, and Stephen Randy Davis 0011__556633448899--ffffiirrss..iinndddd ii 33//2222//1100 55::2299 PPMM C# 2010 All-in-One For Dummies® Published by Wiley Publishing, Inc. 111 River Street Hoboken, NJ 07030-5774 www.wiley.com Copyright © 2010 by Wiley Publishing, Inc., Indianapolis, Indiana Published by Wiley Publishing, Inc., Indianapolis, Indiana Published simultaneously in Canada No part of this publication may be reproduced, stored in a retrieval system or transmitted in any form or by any means, electronic, mechanical, photocopying, recording, scanning or otherwise, except as permit- ted under Sections 107 or 108 of the 1976 United States Copyright Act, without either the prior written permission of the Publisher, or authorization through payment of the appropriate per-copy fee to the Copyright Clearance Center, 222 Rosewood Drive, Danvers, MA 01923, (978) 750-8400, fax (978) 646-8600. Requests to the Publisher for permission should be addressed to the Legal Department, Wiley Publishing, Inc., 10475 Crosspoint Blvd., Indianapolis, IN 46256, (317) 572-3447, fax (317) 572-4355, or online at http://www.wiley.com/go/permissions. Trademarks: Wiley, the Wiley Publishing logo, For Dummies, the Dummies Man logo, A Reference for the Rest of Us!, The Dummies Way, Dummies Daily, The Fun and Easy Way, Dummies.com, and related trade dress are trademarks or registered trademarks of John Wiley & Sons, Inc. and/or its affi liates in the United States and other countries, and may not be used without written permission. All other trademarks are the property of their respective owners. Wiley Publishing, Inc., is not associated with any product or vendor mentioned in this book. LIMIT OF LIABILITY/DISCLAIMER OF WARRANTY: THE PUBLISHER AND THE AUTHOR MAKE NO REPRESENTATIONS OR WARRANTIES WITH RESPECT TO THE ACCURACY OR COMPLETENESS OF THE CONTENTS OF THIS WORK AND SPECIFICALLY DISCLAIM ALL WARRANTIES, INCLUDING WITH- OUT LIMITATION WARRANTIES OF FITNESS FOR A PARTICULAR PURPOSE. NO WARRANTY MAY BE CREATED OR EXTENDED BY SALES OR PROMOTIONAL MATERIALS. THE ADVICE AND STRATEGIES CONTAINED HEREIN MAY NOT BE SUITABLE FOR EVERY SITUATION. THIS WORK IS SOLD WITH THE UNDERSTANDING THAT THE PUBLISHER IS NOT ENGAGED IN RENDERING LEGAL, ACCOUNTING, OR OTHER PROFESSIONAL SERVICES. IF PROFESSIONAL ASSISTANCE IS REQUIRED, THE SERVICES OF A COMPETENT PROFESSIONAL PERSON SHOULD BE SOUGHT. NEITHER THE PUBLISHER NOR THE AUTHOR SHALL BE LIABLE FOR DAMAGES ARISING HEREFROM. THE FACT THAT AN ORGANIZA- TION OR WEBSITE IS REFERRED TO IN THIS WORK AS A CITATION AND/OR A POTENTIAL SOURCE OF FURTHER INFORMATION DOES NOT MEAN THAT THE AUTHOR OR THE PUBLISHER ENDORSES THE INFORMATION THE ORGANIZATION OR WEBSITE MAY PROVIDE OR RECOMMENDATIONS IT MAY MAKE. FURTHER, READERS SHOULD BE AWARE THAT INTERNET WEBSITES LISTED IN THIS WORK MAY HAVE CHANGED OR DISAPPEARED BETWEEN WHEN THIS WORK WAS WRITTEN AND WHEN IT IS READ. For general information on our other products and services, please contact our Customer Care Department within the U.S. at 877-762-2974, outside the U.S. at 317-572-3993, or fax 317-572-4002. For technical support, please visit www.wiley.com/techsupport. Wiley also publishes its books in a variety of electronic formats. Some content that appears in print may not be available in electronic books. Library of Congress Control Number: TK ISBN: 978-0-470-56348-9 Manufactured in the United States of America 10 9 8 7 6 5 4 3 2 1 0011__556633448899--ffffiirrss..iinndddd iiii 33//2222//1100 55::2299 PPMM About the Authors Hi, my name is Bill Sempf, and I am a software architect. Although I used to hate the term architect, it’s clearly the only thing out there that defi nes what I do. My breadth of experience includes business and technical analysis, software design, development, testing, server management and maintenance, and security. In my 17 years of professional experience, I have participated in the creation of well over 200 applications for large and small companies, managed the software infrastructure of two Internet service providers, coded complex software happily in every environment imaginable, and made mainframes talk to cellphones. In short, I make the technology products that people are using every day play nicely together. I started playing with computers in 1979 and haven’t looked back since. In 1985 I was helping my father (also named Bill) manage Apple IIe systems at the local library. Since then I have built applications for the likes of Bank One, Lucent Technologies, Nationwide Insurance, and Sears, Roebuck and Co. I am the author of Visual Basic 2008 For Dummies and Visual Basic 2005 For Dummies; a coauthor of Effective Visual Studio.NET, Professional ASP. NET Web Services, and Professional VB.NET; a frequent contributor to MSDN, Builder.com, Hardcore Web Services, Cloud Computing Journal, Inside Web Development Journal, and Intranet Journal; and have recently been an invited speaker for the ACM and IEEE, DevEssentials, the International XML Web Services Expo, and the Association of Information Technology Professionals. I am a graduate of The Ohio State University with a bachelor’s of science degree in business administration, a Microsoft Certifi ed Professional, a Certifi ed Internet Business Strategist, and a Certifi ed Internet Webmaster. My company is Products Of Innovative New Technology (usually called POINT), and you can reach me at [email protected]. Chuck Sphar escaped the Microsoft C++ documentation camps after six years of hard labor as a senior technical writer. You can reach Chuck for praise and minor nits at [email protected]. His C# material Web page (references throughout the book) is csharp102.info. Stephen R. Davis, who goes by the name Randy, lives with his wife and son near Dallas, Texas. 0011__556633448899--ffffiirrss..iinndddd iiiiii 33//2222//1100 55::2299 PPMM 0011__556633448899--ffffiirrss..iinndddd iivv 33//2222//1100 55::2299 PPMM Dedication This book goes to the active community of Microsoft developers that I get to work with every day. Thanks for your commitment to getting things done right, sharing what you know, and having a good time doing it. Also, for Gabrielle and Adam, who had to put up with another six months of Daddy hiding in the basement. —Sempf Acknowledgments A lot of people work to make a book of this size. Don’t think, just because the authors are listed on the front page, that they conceived every idea in the book. It takes a community. First, thanks to Chuck Sphar and Randy Davis for the fantastic source mate- rial that is the backbone of this book. I learned much just editing the fi rst two minibooks for use in this All-in-One. Also, thanks to Katie Feltman and Chris Morris for their editorial expertise. A number of community members had a huge part in the creation of this book. Carey Payette and Phil Japikse built Book V (about WPF) basically from the goodness of their hearts, and I couldn’t have completed it without them — my WPF skills aren’t worth writing about. These two get the award for Biggest Contribution, and I thank them both. The developers at Information Control Corporation were also essential in for- mulating the initial scope of this book and then fact-checking the details. Steve Webb, Stephen Giffi n, John Hannah, Larry Beall, Michael Birchmeyer, and Azher Muhammad all had a big part, especially in the information related specifi cally to C# 4.0. Thanks to them and all the other ICC experts who gave me ideas and tips. Kevin Pilch-Bisson at Microsoft provided some C# clarity via Twitter through- out the scope of this book. Steve Andrews provided the structure for the T4 chapter in Book IV. Mads Torgerson reviewed the table of contents, and I thank him for the “It looks delicious” phrase, which I think was my most quoted phrase of the year. Lars Corneliussen provided a few choice pointers for the book, and Julie Lerman’s Entity Framework writing was the basis of my own additions to the ADO.NET chapter. As always, thanks to my wife, Gabrielle, for her support. Sometimes I just can’t believe how lucky I am. 0011__556633448899--ffffiirrss..iinndddd vv 33//2222//1100 55::2299 PPMM Publisher’s Acknowledgments We’re proud of this book; please send us your comments at http://dummies.custhelp.com. For other comments, please contact our Customer Care Department within the U.S. at 877-762-2974, outside the U.S. at 317-572-3993, or fax 317-572-4002. Some of the people who helped bring this book to market include the following: Acquisitions, Editorial, and Media Composition Services Development Project Coordinator: Sheree Montgomery Senior Project Editor: Christopher Morris Layout and Graphics: Samantha K. Cherolis, Acquisitions Editor: Katie Feltman Nikki Gately, Joyce Haughey Copy Editors: Debbye Butler, Heidi Unger, Proofreader: Christine Sabooni Becky Whitney Indexer: Broccoli Information Mgt. Technical Editor: Mike Spivey Editorial Manager: Kevin Kirschner Media Development Project Manager: Laura Moss-Hollister Media Development Assistant Project Manager: Jenny Swisher Media Development Associate Producers: Josh Frank, Marilyn Hummel, Douglas Kuhn, Shawn Patrick Editorial Assistant: Amanda Graham Sr. Editorial Assistant: Cherie Case Cartoons: Rich Tennant (www.the5thwave.com) Publishing and Editorial for Technology Dummies Richard Swadley, Vice President and Executive Group Publisher Andy Cummings, Vice President and Publisher Mary Bednarek, Executive Acquisitions Director Mary C. Corder, Editorial Director Publishing for Consumer Dummies Diane Graves Steele, Vice President and Publisher Composition Services Debbie Stailey, Director of Composition Services 0011__556633448899--ffffiirrss..iinndddd vvii 33//2222//1100 55::2299 PPMM Contents at a Glance Introduction ................................................................ 1 Book I: Basics of C# Programming ................................ 9 Chapter 1: Creating Your First C# Console Application .............................................11 Chapter 2: Living with Variability — Declaring Value-Type Variables .....................25 Chapter 3: Pulling Strings ...............................................................................................45 Chapter 4: Smooth Operators ........................................................................................73 Chapter 5: Getting Into the Program Flow ....................................................................85 Chapter 6: Lining Up Your Ducks with Collections ...................................................109 Chapter 7: Stepping through Collections....................................................................135 Chapter 8: Buying Generic ............................................................................................169 Chapter 9: Some Exceptional Exceptions ...................................................................187 Book II: Object-Oriented C# Programming ................. 205 Chapter 1: Object-Oriented Programming: What’s It All About? .............................207 Chapter 2: Showing Some Class ...................................................................................215 Chapter 3: We Have Our Methods ...............................................................................227 Chapter 4: Let Me Say This about this......................................................................247 Chapter 5: Holding a Class Responsible .....................................................................261 Chapter 6: Inheritance: Is That All I Get? ....................................................................285 Chapter 7: Poly-what-ism? ............................................................................................307 Chapter 8: Interfacing with the Interface ....................................................................333 Chapter 9: Delegating Those Important Events .........................................................357 Chapter 10: Can I Use Your Namespace in the Library? ...........................................377 Book III: Designing for C# ........................................ 399 Chapter 1: Writing Secure Code ...................................................................................401 Chapter 2: Accessing Data ............................................................................................415 Chapter 3: Fishing the FileStream ................................................................................435 Chapter 4: Accessing the Internet ...............................................................................455 Chapter 5: Creating Images...........................................................................................469 0022__556633448899--ffttoocc..iinndddd vviiii 33//1199//1100 88::0011 PPMM Book IV: A Tour of Visual Studio ............................... 479 Chapter 1: Getting Started with Visual Studio ...........................................................481 Chapter 2: Using the Interface ......................................................................................495 Chapter 3: Customizing Visual Studio .........................................................................517 Chapter 4: Transforming Text Templates...................................................................533 Book V: Windows Development with WPF .................. 543 Chapter 1: Introducing WPF .........................................................................................545 Chapter 2: Understanding the Basics of WPF.............................................................555 Chapter 3: Data Binding in WPF ...................................................................................579 Chapter 4: Practical WPF ..............................................................................................601 Book VI: Web Development with ASP.NET.................. 627 Chapter 1: Looking at How ASP.NET Works with C# .................................................629 Chapter 2: Building Web Applications ........................................................................641 Chapter 3: Controlling Your Development Experience .............................................659 Chapter 4: Leveraging the .NET Framework ...............................................................685 Chapter 5: Digging into Web Construction .................................................................703 Book VII: Service-Oriented Development .................... 717 Chapter 1: Getting Acquainted with Web Services ....................................................719 Chapter 2: Building Web Services with ASMX ............................................................731 Chapter 3: Building Web Services with WCF ..............................................................745 Chapter 4: Building Web Services with ReST .............................................................759 Book VIII: New Features in C# 4.0 ............................ 767 Chapter 1: Programming Dynamically! .......................................................................769 Chapter 2: Improving Productivity with Named and Optional Parameters ...........781 Chapter 3: Helping Out with Interop ...........................................................................789 Chapter 4: Revising Generics .......................................................................................795 Index ...................................................................... 799 0022__556633448899--ffttoocc..iinndddd vviiiiii 33//1199//1100 88::0011 PPMM

See more

The list of books you might like

Most books are stored in the elastic cloud where traffic is expensive. For this reason, we have a limit on daily download.