When I first started working with Microsoft Visual C# .NET, I was immediately struck by how productive my coding sessions became. Even though I was working with the pre-Beta release, the development environment and the .NET Framework simplified much of the work that I was doing. The increased productivity was due to four factors:

  • The C# programming language, which is well-suited for component-based development
  • The simplified programming and deployment model offered by the common language runtime
  • The .NET Framework and its associated class library
  • The developer automation features included in the Microsoft Visual Studio .NET environment

The tools for development that are realized today with Visual C# .NET are light-years ahead of the tools I was using in the mid-1980s when I started developing for Microsoft Windows. When I was asked to write a book about Visual C# .NET, I just couldn’t refuse. I’m sure that you’ll find working with Visual C# .NET a rewarding experience, and I’m pleased that you’ve selected this book to help get you started.

I enjoy talking to readers, and I’m happy to answer any questions you might have after reading my books. If you have any feedback or questions about this text, feel free to contact me at I can’t always respond immediately, but I try to answer all of my e-mail.

Who Should Read This Book

This book is intended for developers who want to learn the C# programming language using Microsoft Visual C# .NET. The book is intended to provide a broad overview of programming with Visual C# .NET, so it explores a wide variety of topics. In addition to a discussion of the C# programming language, this book covers the more commonly used classes in the .NET Framework, including Windows Forms programming, ASP.NET, Extensible Markup Language (XML), Web services, and more.

System Requirements

To use this book, you’ll need to have Visual C# .NET or Visual Studio .NET installed on your computer. Any computer that satisfies the minimum require-ments for Visual C# .NET will work effectively with most of the examples in this book. Be aware that Microsoft Windows XP Home Edition and Microsoft Win-dows NT 4 don’t support the hosting of XML Web services or ASP.NET Web applications with the .NET Framework. Although you can build these projects on these operating systems, you’ll need to upload the projects to a properly configured host to execute them. I recommend that development be done on the Microsoft Windows XP Professional or Microsoft Windows 2000 Profes-sional operating systems. For Chapter 20, you need IIS version 4 or later in order to run the sample code.


This book is arranged in five parts, with each part covering a different aspect of programming using Visual C# .NET:

  • Part I Introduces the Visual C# .NET environment and examines the core portions of the C# programming language.
  • Part II Describes the more advanced aspects of the C# programming language and the .NET Framework. In addition to chapters on delegates and exception handling, we’ll cover topics such as collection classes, debugging, and writing multithreaded code.
  • Part III Here you’ll learn how to write graphical user interface (GUI) applications using Visual C# .NET. The .NET Framework includes extensive support for writing Windows Forms–based applications, and you’ll see that many advanced controls are very easy to use.
  • Part IV Examines ADO.NET and XML. You’ll learn how to use ADO.NET for data access to databases such as SQL Server. We’ll also look at the .NET Framework classes that implement a new model for manipulating XML, in which data is pulled from an XML stream. With the .NET Framework and Visual C# .NET, it’s easy to manage data using either ADO.NET or XML.
  • Part V The book wraps up with a discussion of creating Web applications using ASP.NET and Visual C# .NET and shows you how to use XML Web services.
Sample Files

Supplemental content for this book, including sample files, can be found at the Microsoft Press Web site, at Clicking the Companion Content link takes you to a page from which you can download the samples.

The sample files can also be found on the book’s companion CD, along with other supplemental content. To access those files, insert the companion CD in your computer’s CD-ROM drive and make a selection from the menu that appears. If the AutoRun feature is not enabled on your system (if a menu doesn’t appear when you insert the disc in your computer’s CD-ROM drive), run StartCD.exe in the root folder of the companion CD. Installing the sample files on your hard disk requires approximately 7.8 MB of disk space. If you have trouble running any of these files, refer to the text in the book that describes these programs.

Aside from the sample files that this book discusses, the book’s supple-mental content includes two eBook installations: a stand-alone eBook installa-tion, and a Visual Studio Help eBook installation. The stand-alone eBook installation will allow you to access an electronic version of the print book directly from your desktop. The Visual Studio Help eBook installation will allow you to access a second electronic version of the print book directly from the Visual Studio .NET help system.

Visual Studio .NET Professional Trial Version

In addition to the companion CD, this book includes a DVD with an evaluation copy of Microsoft Visual Studio .NET Professional. This evaluation copy can help you follow the examples in this book and get you started learning Microsoft Visual C# .NET, but the software must be activated and it will expire and stop working 60 days after you install it. Also, your computer must have a DVD-ROM drive. You can learn more about this evaluation copy and its system requirements at


Every effort has been made to ensure the accuracy of this book and the con-tents of the companion CD. Microsoft Press provides corrections for books through the World Wide Web at the following address: .

To connect directly to the Microsoft Press Knowledge Base and enter a query regarding a question or an issue that you may have, go to: If you have comments, questions, or ideas regarding this book or the com-panion content, or questions that are not answered by querying the Knowledge Base, please send them to Microsoft Press via e-mail to:

Or via postal mail to: Microsoft Press
Attn: Microsoft Visual C# .NET (Core Reference) Editor
One Microsoft Way
Redmond, WA 98052-6399

Please note that product support is not offered through the above addresses. For product support information, please visit the Microsoft Support Web site at:

Part III: Programming Windows Forms