Programming With C#
Programming With C#
Delivery Guide
Course Number: 2124C
Information in this document, including URL and other Internet Web site references, is subject to
change without notice. Unless otherwise noted, the example companies, organizations, products,
domain names, e-mail addresses, logos, people, places, and events depicted herein are fictitious,
and no association with any real company, organization, product, domain name, e-mail address,
logo, person, places or events is intended or should be inferred. Complying with all applicable
copyright laws is the responsibility of the user. Without limiting the rights under copyright, no
part of this document may be reproduced, stored in or introduced into a retrieval system, or
transmitted in any form or by any means (electronic, mechanical, photocopying, recording, or
otherwise), or for any purpose, without the express written permission of Microsoft Corporation.
Microsoft may have patents, patent applications, trademarks, copyrights, or other intellectual
property rights covering subject matter in this document. Except as expressly provided in any
written license agreement from Microsoft, the furnishing of this document does not give you any
license to these patents, trademarks, copyrights, or other intellectual property.
20012002 Microsoft Corporation. All rights reserved.
Microsoft, MS-DOS, Windows, Windows NT, ActiveX, BizTalk, IntelliSense, JScript, MSDN,
PowerPoint, SQL Server, Visual Basic, Visual C++, Visual C#, Visual J#, Visual Studio, and
Win32 are either registered trademarks or trademarks of Microsoft Corporation in the U.S.A.
and/or other countries.
The names of actual companies and products mentioned herein may be the trademarks of their
respective owners.
Programming with C#
Contents
iii
Introduction
Course Materials ......................................................................................................2
Prerequisites.............................................................................................................3
Course Outline .........................................................................................................4
Microsoft Certified Professional Program ...............................................................7
Facilities.................................................................................................................10
Module 2: Overview of C#
Overview..................................................................................................................1
Structure of a C# Program .......................................................................................2
Basic Input/Output Operations.................................................................................9
Recommended Practices ........................................................................................15
Compiling, Running, and Debugging ....................................................................22
Lab 2.1: Creating a Simple C# Program ................................................................36
Review ...................................................................................................................44
iv
Programming with C#
Module 6: Arrays
Overview................................................................................................................. 1
Overview of Arrays................................................................................................. 2
Creating Arrays ..................................................................................................... 10
Using Arrays ......................................................................................................... 17
Lab 6.1: Creating and Using Arrays ..................................................................... 29
Review .................................................................................................................. 40
Programming with C#
Programming with C#
vii
Description
This five-day instructor-led course provides students with the knowledge and
skills needed to develop C# applications for the Microsoft .NET Platform. The
course focuses on C# program structure, language syntax, and implementation
details.
Audience
This course is intended for experienced developers who already have
programming experience in C, C++, Microsoft Visual Basic, or Java. These
developers will be likely to develop enterprise business solutions.
Student Prerequisites
This course requires that students meet the following prerequisites:
Familiarity with the .NET Framework as described on the MSDN Web site
(http://msdn.microsoft.com/library/default.asp?url=/library
/en-us/cpguidnf/html/cpovrintroductiontonetframeworksdk.asp)
viii
Programming with C#
Course Objectives
After completing this course, the student will be able to:
List the major elements of the .NET Framework, and explain how C# fits
into the .NET Platform.
Create methods (functions and subroutines) that can return values and take
parameters.
Programming with C#
Course Timing
The following schedule is an estimate of the course timing. Your timing may
vary.
Day 1
Start
End
Module
9:00
9:30
Introduction
9:30
10:00
10:00
10:15
Break
10:15
11:15
Module 2: Overview of C#
11:15
12:15
12:15
1:15
Lunch
1:15
2:15
2:15
3:15
3:15
3:30
Break
3:30
4:00
4:00
4:30
4:30
5:00
Start
End
Module
9:00
9:30
Day 1 review
9:30
10:00
10:00
10:15
Break
10:15
11:15
11:15
12:15
12:15
1:15
Lunch
1:15
2:00
Module 6: Arrays
2:00
3:00
3:00
3:15
Break
3:15
4:00
4:00
4:45
4:45
5:00
Day 2
ix
Programming with C#
Day 3
Start
End
Module
9:00
9:30
Day 2 review
9:30
10:30
10:30
10:45
Break
10:45
11:30
11:30
12:00
12:00
1:00
Lunch
1:00
1:30
1:30
2:30
2:30
2:45
Break
2:45
3:45
3:45
4:15
4:15
4:30
4:30
5:00
Start
End
Module
9:00
9:30
Day 3 review
9:30
10:30
10:30
10:45
Break
10:45
12:00
12:00
1:00
Lunch
1:00
1:45
1:45
2:15
2:15
2:30
Break
2:30
3:00
3:00
3:30
3:30
4:30
Day 4
Programming with C#
Day 5
Start
End
Module
9:00
9:30
Day 4 review
9:30
10:00
10:00
10:30
10:30
10:45
Break
10:45
11:15
11:15
11:45
11:45
12:15
12:15
1:15
Lunch
1:15
2:15
2:15
3:00
3:00
4:00
Course review
xi
xii
Programming with C#
Autorun.exe. When the CD is inserted into the CD-ROM drive, or when you
double-click the autorun.exe file, this file opens the CD and allows you to
browse the Student or Trainer compact disc.
Autorun.inf. When the compact disc is inserted into the compact disc drive,
this file opens Autorun.exe.
Readme.txt. This file explains how to install the software for viewing the
Trainer Materials compact disc and its contents and how to open the Trainer
Materials Web page.
Powerpnt. This folder contains the Microsoft PowerPoint slides that are
used in this course.
Setup. This folder contains the files that install the course and related
software to computers in a classroom setting.
StudentCD. This folder contains the Web page that provides students with
links to resources pertaining to this course, including additional reading,
review and lab answers, lab files, multimedia presentations, and courserelated Web sites.
Tools. This folder contains files and utilities used to complete the setup of
the instructor computer.
Webfiles. This folder contains the files that are required to view the course
Web page. To open the Web page, open Windows Explorer, and in the root
directory of the compact disc, double-click Default.htm or Autorun.exe.
Programming with C#
xiii
Autorun.exe. When the CD is inserted into the CD-ROM drive, or when you
double-click the autorun.exe file, this file opens the CD and allows you to
browse the Student Materials compact disc.
Autorun.inf. When the compact disc is inserted into the compact disc drive,
this file opens Autorun.exe.
Default.htm. This file opens the Student Materials Web page. It provides
students with resources pertaining to this course, including additional
reading, review and lab answers, lab files, multimedia presentations, and
course-related Web sites.
Readme.txt. This file explains how to install the software for viewing the
Student Materials compact disc and its contents and how to open the
Student Materials Web page.
Flash. This folder contains the installer for the Macromedia Flash 5.0
browser plug-in.
Fonts. This folder contains fonts that are required to view the Microsoft
PowerPoint presentation and Web-based materials.
Labs. This folder contains files that are used in the hands-on labs. These
files may be used to prepare the student computers for the hands-on labs.
Media. This folder contains files that are used in multimedia presentations
for this course.
Mplayer. This folder contains the setup file to install Microsoft Windows
Media Player.
Webfiles. This folder contains the files that are required to view the course
Web page. To open the Web page, open Windows Explorer, and in the root
directory of the compact disc, double-click Default.htm or Autorun.exe.
Wordview. This folder contains the Word Viewer that is used to view any
Word document (.doc) files that are included on the compact disc.
xiv
Programming with C#
Document Conventions
The following conventions are used in course materials to distinguish elements
of the text.
Convention
Use
bold
italic
Title Capitals
ALL CAPITALS
monospace
[]
{}
...
.
.
.