C# Bible Jeff Ferguson, Brian Patterson, Jason Beres, Pierre Boutquin, and Meeta Gupta Published by Wiley Publishing, Inc 10475 Crosspoint Boulevard Indianapolis,_IN 46256 www.wiley.com Copyright © 2002 by Wiley Publishing, Inc., Indianapolis, Indiana Published simultaneously in Canada Library of Congress Control Number: 2001092884 ISBN: 0-7645-4834-4 Manufactured in the United States of America 10 1B/ST/QX/QS/IN 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 permitted 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) 750-4744 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-4447, E-Mail: permcoordinator@wiley.com LIMIT OF LIABILITY/DISCLAIMER OF WARRANTY: WHILE THE PUBLISHER AND AUTHOR HAVE USED THEIR BEST EFFORTS IN PREPARING THIS BOOK, THEY MAKE NO REPRESENTATIONS OR WARRANTIES WITH RESPECT TO THE ACCURACY OR COMPLETENESS OF THE CONTENTS OF THIS BOOK AND SPECIFICALLY DISCLAIM ANY IMPLIED WARRANTIES OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE NO WARRANTY MAY BE CREATED OR EXTENDED BY SALES REPRESENTATIVES OR WRITTEN SALES MATERIALS THE ADVICE AND STRATEGIES CONTAINED HEREIN MAY NOT BE SUITABLE FOR YOUR SITUATION YOU SHOULD CONSULT WITH A PROFESSIONAL WHERE APPROPRIATE NEITHER THE PUBLISHER NOR AUTHOR SHALL BE LIABLE FOR ANY LOSS OF PROFIT OR ANY OTHER COMMERCIAL DAMAGES, INCLUDING BUT NOT LIMITED TO SPECIAL, INCIDENTAL, CONSEQUENTIAL, OR OTHER DAMAGES For general information on our other products and services or to obtain technical support, please contact our Customer Care Department within the U.S at 800-762-2974, outside the U.S at (317) 572-3993 or fax (317) 572-4002 Wiley also publishes its books in a variety of electronic formats Some content that appears in print may not be available in electronic books Trademarks: Wiley, the Wiley Publishing logo and related trade dress are trademarks or registered trademarks of Wiley Publishing, Inc., 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 About the Authors Jeff Ferguson is a senior consultant with Magenic Technologies, a software consulting company dedicated to solving business problems exclusively using Microsoft tools and technologies He has been a professional software developer since 1989 and has developed software using C, C++, and C# for Unix, DOS, and Windows systems Send e-mail to Jeff at JeffF@magenic.com (remember to include all three "F"s in the name portion of the address) Brian Patterson currently works for Affina, Inc., as a Technical Team Leader, where he is generally working with C++ on HP-UX or Windows development with any number of the Visual Studio languages Brian has been writing for various Visual Basic publications since 1994 and has co-written several NET-related books, including Migrating to Visual Basic NET and NET Enterprise Development with VB.NET You can generally find him posting in the MSDN newsgroups or you can reach him by e-mail at BrianDPatterson@msn.com Jason Beres has been a software developer for 10 years He is currently a consultant in south Florida and works exclusively with Microsoft technologies Jason holds the MCT, MCSD, and MCDBA certifications from Microsoft When he is not teaching, consulting, or writing, he is formatting his hard drive, installing the latest beta products from Microsoft, and keeping up with the latest episodes of "Star Trek." Pierre Boutquin is a senior software architect in the treasury of a major Canadian bank, where he helps develop leading-edge market risk management software He has more than a decade of experience implementing PC-based computer systems, with in-depth knowledge of distributed systems design, data warehousing, Visual Basic, Visual C++, and SQL He has cowritten many programming books and has contributed material on VB, COM+, XML, and SQL to other books Koshka and Sasha, his two adorable Burmese cats, own most of Pierre's spare time While petting them, he often thinks how nice it would be to find more time and get back into chess or keep up with news from Belgium, his native country You can reach him at boutquin@hotmail.com Meeta Gupta has a master's degree in computer engineering Networking is her first love She is presently working at NIIT Ltd., where she designs, develops, and authors books on a varied range of subjects She has co-written books on TCP/IP, A+ Certification, ASP.NET, and PHP She also has an extensive experience in designing and developing ILTs Besides writing, Meeta has conducted courses on C++, Sybase, Windows NT, Unix, and HTML for a diverse audience, from students to corporate clients NIIT is a global IT solutions company that creates customized multimedia training products and has more than 2,000 training centers worldwide NIIT has more than 4,000 employees in 37 countries and has strategic partnerships with a number of major corporations, including Microsoft and AT&T About the Series Editor Michael Lane Thomas is an active development community and computer industry analyst who presently spends a great deal of time spreading the gospel of Microsoft NET in his current role as a NET technology evangelist for Microsoft In working with over a half-dozen publishing companies, Michael has written numerous technical articles and written or contributed to almost 20 books on numerous technical topics, including Visual Basic, Visual C++, and NET technologies He is a prolific supporter of the Microsoft certification programs, having earned his MCSD, MCSE+I, MCT, MCP+SB, and MCDBA In addition to technical writing, Michael can also be heard over the airwaves from time to time, including two weekly radio programs on Entercom (http://www.entercom.com/) stations, including most often in Kansas City on News Radio 980KMBZ (http://www.kmbz.com/) He can also occasionally be caught on the Internet doing an MSDN Webcast (http://www.microsoft.com/usa/webcasts/) discussing NET, the next generation of Web application technologies Michael started his journey through the technical ranks back in college at the University of Kansas, where he earned his stripes and a couple of degrees After a brief stint as a technical and business consultant to Tokyo-based Global Online Japan, he returned to the States to climb the corporate ladder He has held assorted roles, including those of IT manager, field engineer, trainer, independent consultant, and even a brief stint as Interim CTO of a successful dot-com, although he believes his current role as NET evangelist for Microsoft is the best of the lot He can be reached via e-mail at mlthomas@microsoft.com Credits Senior Acquisitions Editor Sharon Cox Project Editor Eric Newman Development Editor Sydney Jones Copy Editor Luann Rouff Technical Editor Sundar Rajan Editorial Manager Mary Beth Wakefield Vice President & Executive Group Publisher Richard Swadley Vice President and Publisher Joseph B Wikert Project Coordinator Ryan T Steffen Graphics and Production Specialists Beth Brooks, Melanie DesJardins, Joyce Haughey, Barry Offringa, Laurie Petrone, Betty Schulte, Jeremey Unger Quality Control Technicians Laura Albert, Susan Moritz Proofreading and Indexing TECHBOOKS Production Services For my family and my friends Jeff Ferguson This book is dedicated to my uncle, Brian Weston, who didn't seem to mind when I came to visit and spent all day with his TRS-80 Model II Brian Patterson element contains Title, or more Category, and or more Author. The Title, Category, and Author elements contain text. A Book has required attribute. The following XML document shows how to create an XML document that refers to a schema using name spaces This is done by adding three attributes to the root element The first attribute defines the prefix used by the namespace and the unique string associated with this namespace The second attribute specifies which version of the XML Schemas you are using Finally, the third attribute tells you which namespace the XML Schema is using and where the XML Schema is located XML By Example Web Development Benoit Marchal XML in Action Internet XML William J Pardy Because most elements in an XML document belong to the same namespace, it is possible to create a default namespace and omit the namespace prefix, for example, xmlns ="www.myurl.com" Lastly, it is possible to have several namespace declarations in the same XML document This is done by adding all the namespace attributes to the root element Note that a document can only point to XML Schema though ... numerous technical topics, including Visual Basic, Visual C+ +, and NET technologies He is a prolific supporter of the Microsoft certification programs, having earned his MCSD, MCSE+I, MCT, MCP+SB,... RESPECT TO THE ACCURACY OR COMPLETENESS OF THE CONTENTS OF THIS BOOK AND SPECIFICALLY DISCLAIM ANY IMPLIED WARRANTIES OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE NO WARRANTY MAY BE CREATED... often in Kansas City on News Radio 980KMBZ (http://www.kmbz.com/) He can also occasionally be caught on the Internet doing an MSDN Webcast (http://www.microsoft.com/usa/webcasts/) discussing NET,