Read Microsoft Visual C# 2005 Express Edition: Build a Program Now! Online
Authors: Patrice Pelland
Tags: #General, #Computers, #C♯ (Computer program language), #Programming Languages, #C#, #Microsoft .NET Framework, #Computer Books: Languages, #Computer Graphics, #Application software, #C# (Computer program language), #Programming, #Microsoft Visual C# .NET, #Microsoft Visual C♯ .NET, #Electronic books, #Game Programming & Design, #Computing: Professional & Programming, #C (Computer program language), #Computers - Languages, #Programming Languages - C#, #Programming & scripting languages: general
10/24/05 5:19:01 PM
Prerelease Software
Questions and Comments
This book was reviewed and tested against the August 2005
If you have comments, questions, or ideas regarding the
release candidate. This book is expected to be fully compatbook or the companion content or have questions that are ible with the final release of Visual Studio 2005. If there are
not answered by visiting the sites above, please send them
any changes or corrections for this book, they’ll be collected
to Microsoft Press via e-mail to
and added to a Microsoft Knowledge Base article. See the
“Support for This Book” section in this Introduction for more
information.
or via postal mail to
Technology Updates
Microsoft Press
Attn: Visual C# 2005 Express Edition: Build a Program
As technologies related to this book are updated, links to
Now! Editor
additional information will be added to the Microsoft Press
One Microsoft Way
Technology Updates Web page. Visit this page periodically
Redmond, WA 98052-6399
for updates on Visual Studio 2005 and other technologies.
Please note that Microsoft offers no software product
http://www.microsoft.com/mspress/updates/
support through these addresses.
Support for This Book
Every effort has been made to ensure the accuracy of this
book and the companion content. As corrections or changes
are collected, they’ll be added to a Microsoft Knowledge
Base article. To view the list of known corrections for this
book, visit the following article:
http://support.microsoft.com/kb/905040
Microsoft Press provides support for books and companion content at the following Web site:
http://www.microsoft.com/learning/support/books/
Introduction
ix
A02622299.indd ix
A02622299.indd ix
10/24/05 5:19:01 PM
10/24/05 5:19:01 PM
About the Author
Patrice Pelland
beautiful; she’s my idol, my inspiration, my sunshine, my
best friend, my love, and an awesome mother! Mon amour,
Patrice Pelland is a technical lead at Microsoft working in
thanks for being who you are and for being there for me! I
the Developer Division. He loves .NET and Web services
love you!
and, for the past four years, he has been working, teaching,
evangelizing, and talking about them to everyone.
Thanks
For the past twelve years, he has been working in
software development in various roles: developer, project
First of all, thanks to my parents. Mom, Dad, you gave me
lead, manager and mentor, and software engineer in QA
all the chances to be what I am in life and you gave me the
organizations. He has vast experience spanning multiple
values to be the man I am. Thanks and I love you!
technologies and fields: developer tools, fiber optics teleA book is a huge adventure in somebody’s life, and it communication, aviation, coffee and dairy companies, and
would not be possible without the help of many people. I’ve
also three years teaching computer science and software
always read the thank you sections in other people’s books
development at a college in Canada.
and I was always amazed at how many people are needed
When not developing great tools for developers and
to make a book what it is. Now I really understand why!!!
helping customers throughout the world, he enjoys spendWhile writing a book is tough, real tough, it’s really sating time with his family and friends, playing games on isfying at the same time. During the writing process, you
XBOX and PC, reading books, reading about Porsche and
sometimes have doubts, and I had my share of--especially
dreaming about driving one, playing hockey, watching
those nights at 3:00 a.m. when all other souls in the house
NHL hockey and NFL football, and having great dinners
are asleep, even my dog, and the product had a bug prewith good food and fine drinks with friends and family. He venting me from testing something; when I was in front of
resides with his family in Sammamish, WA.
my laptop with an exception and a white page in Word;
when everybody was on vacation this summer while I was
Dedication
working at the library in Sammamish. I can’t remember
how many times I’ve said to my friends, “No, I won’t be
This book is dedicated to my wife, Hélène. My wife is a breast
able to be there. I need to work on my book!” But it’s an
cancer survivor, and her courage and strength push me to
awesome experience to write a book; everybody who has
do better things and to face more complex challenges. She’s
the chance should take the challenge!
x
Microsoft Visual C# 2005 Express Edition: Build a Program Now!
A02622299.indd x
A02622299.indd x
10/24/05 5:19:01 PM
10/24/05 5:19:01 PM
With that said, I first need to thank my lovely family. My
A special thanks to Jeff Prosise for being such a good
kids (Laura, 11, and Antoine, 9) and my wife, Hélène, were
writer, an awesome trainer, and for writing a blog about the
so great and PATIENT. How many times I heard them say,
writing process. You were the spark that ignited my flame to
“Daddy, it’s movie night…oh yeah, it’s true, you’re workwrite a technical book. ing on your book again!” But at the same time, they were
Thanks also to my colleagues from the DDCPX team for
respecting the space I needed and the time alone!!! You
always giving me good words of encouragement, to Boris
guys are great and I love you!
Feldman for sharing his experiences as a writer and, finally,
I have to thank all the people at MS Learning and the
thanks to my good friend, John Cross, for his constructive
publishing team. I would especially like to thank Ben for
feedback.
helping me get in the writing world; Sandra for her constant
Thanks to my good friends here in the Puget Sound area
motivation, help, suggestions, and also for helping me to go
for the kind words of encouragement and to my family and
through all the hurdles of writing a book; and Megan for all
friends in Canada for understanding why I’m not calling or
your help getting the job done and a real, tangible product.
giving any news. Sorry, Mom and Dad!
You guys have my respect for working day in, day out in the
And thanks to my good neighbors and friends, Mike and
crazy world of publishing.
Elizabeth, for their constant encouragement and for letting
I would also like to thank all the people in the VB, C#,
me use their dog’s name, Molly, in my OOP introduction.
Windows Forms, MSDN and setup teams who helped me
Thanks to everybody I might have forgotten!
by answering all my questions in a dynamic and constantly
changing product lifecycle. I would like to thank more
Patrice Pelland
specifically Dan Fernandez, Joe Binder, Brian Keller, Brian
October 2005
Johnson, Hong Gao, Jay Roxe, Kavitha Radhakrishnan, Kent
Sammamish, WA
Sharkey, Lisa Feigenbaum, Shamez Rajan, Steve Lasker, Aaron
Stebner, and Habib Heydarian.
Chapter #: Chapter Title
xi
A02622299.indd xi
A02622299.indd xi
10/24/05 5:19:03 PM
10/24/05 5:19:03 PM
A02622299.indd xii
A02622299.indd xii
10/24/05 5:19:04 PM
10/24/05 5:19:04 PM
Introducing
Microsoft® Visual C#®
2005 Express Edition
What Is .NET?, 2
So maybe you’ve decided you want to try programming and you found
yourself with this book. Well, if that’s the case, you’ve come to the right
What Is C#?, 4
place. This book is all about introducing you to the art, science, and joys of creating software for Microsoft Windows®; yes, the same Microsoft
What Is Visual C# 2005
Express Edition?, 9
Windows you probably use every day. Throughout the book, I’ll show you how to build applications that are very similar to many of the applications you use on a regular basis, such as your Internet browser, your word proces
1
sor, your e-mail software, and your personal finance application. You’re probably wondering how you could possibly do this with no programming
experience. By the time you finish this book, you’ll believe it. Don’t worry. We’ll have a blast, and because you’ll actually be building the applications as you follow along with each exercise, you’ll see for yourself just how easy it can be.
1
CSX_Chapter1.indd 1
CSX_Chapter1.indd 1
10/24/05 2:49:18 PM
10/24/05 2:49:18 PM
What Is .NET?
So now, what is that
.NET
thing that everybody is talking about? Maybe you’ve seen it somewhere online or have come across the term in the jobs section in your Sunday newspaper. For instance, the term might have appeared when you were logging on to Hotmail® or in an online ad where a company is looking for a developer with .NET skills. Look at Figure 1-1 for some examples of where you might have come across a reference to .NET. The Platforms SDK team is looking for a strong developer to work on our internal Tools team. The Tools team produces tools and Web sites that track WinFX API development, report metrics on our SDKs, and track the tens of thousands of files that are submitted to our SDKs for WinFX, the .NET Framework, and the Microsoft Windows operating systems.