CSharp - Introduction To C# Programming For The Microsoft - Net Platform Pre Release)
CSharp - Introduction To C# Programming For The Microsoft - Net Platform Pre Release)
CSharp - Introduction To C# Programming For The Microsoft - Net Platform Pre Release)
(Prerelease)
Workbook
Course Number: 2124A
This course is based on the prerelease Beta 1 version of Microsoft® Visual Studio .NET.
Content in the final release of the course may be different from the content included in this
prerelease version. All labs in the course are to be completed with the Beta 1 version of
Visual Studio .NET.
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.
Other product and company names mentioned herein may be the trademarks of their respective
owners.
Contents
Introduction
Course Materials.......................................................................................... 2
Prerequisites................................................................................................ 3
Course Outline ................................ ................................ ............................ 4
Course Outline (continued) ........................................................................... 5
Course Outline (continued) ........................................................................... 6
Microsoft Certified Professional Program ....................................................... 7
Facilities..................................................................................................... 9
Module 1: Overview of the Microsoft .NET Platform
Overview................................ ................................ ................................ .... 1
Introduction to the .NET Platform.................................................................. 2
Overview of the .NET Framework ................................................................. 4
Benefits of the .NET Framework ................................................................... 5
The .NET Framework Components ................................................................ 7
Languages in the .NET Framework.............................................................. 13
Review ..................................................................................................... 14
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: Creating a Simple C# Program........................................................... 36
Review ..................................................................................................... 45
Module 3: Using Value-Type Variables
Overview................................ ................................ ................................ .... 1
Common Type System ................................................................................. 2
Naming Variables ........................................................................................ 9
Using Built- in Data Types........................................................................... 15
Compound Assignment .............................................................................. 18
Increment and Decrement........................................................................... 20
Creating User-Defined Data Types............................................................... 24
Converting Data Types ............................................................................... 28
Lab 3: Creating and Using Types ................................................................. 32
Review ..................................................................................................... 36
Module 4: Statements and Exceptions
Overview................................ ................................ ................................ .... 1
Introduction to Statements................................ ................................ ............ 2
Using Selection Statements ........................................................................... 6
Using Iteration Statements ................................ ................................ .......... 17
Using Jump Statements............................................................................... 29
Lab 4.1: Using Statements ................................ ................................ .......... 32
Handling Basic Exceptions ......................................................................... 41
Raising Exceptions .................................................................................... 51
iv Introduction to C# Programming for the Microsoft® .NET Platform (Prerelease)
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:
n Experience programming in C, C++, Visual Basic, Java, or another
programming language
n Familiarity with Microsoft’s .NET strategy as described on
Microsoft’s .NET Web site: http://www.microsoft.com/net/
n Familiarity with the .NET Framework as described in Microsoft MSDN®
Magazine:
http://msdn.microsoft.com/msdnmag/issues/0900/Framework/
Framework. asp
and
http://msdn.microsoft.com/msdnmag/issues/1000/Framework2/
Framework2.asp
viii Introduction to C# Programming for the Microsoft® .NET Platform (Prerelease)
Course Objectives
After completing this course, the student will be able to:
n List the major elements of the .NET Framew ork and explain how C# fits
into the .NET platform.
n Analyze the basic structure of a C# application and be able to debug,
compile, and run a simple application.
n Create, name, and assign values to variables.
n Use common statements to implement flow control, looping, and exception
handling.
n Create methods (functions and subroutines) that can return values and take
parameters.
n Create, initialize, and use arrays.
n Explain the basic concepts and terminology of object-oriented programming.
n Use common objects and references types.
n Create, initialize, and destroy objects in a C# application.
n Build new C# classes from existing classes.
n Create self-contained classes and frameworks in a C# application.
n Define operators and add event specifications.
n Implement properties and indexers.
n Use predefined and custom attributes.
Introduction to C# Programming for the Microsoft® .NET Platform (Prerelease) ix
n 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.
n Wordview. This folder contains the Word Viewer that is used to view any
Word document (.doc) files that are included on the compact disc. If no
Word documents are included, this folder does not appear.
Introduction to C# Programming for the Microsoft® .NET Platform (Prerelease) xi
Document Conventions
The following conventions are used in course materials to distinguish elements
of the text.
Convention Use
u Indicates an introductory page. This symbol appears next
to a topic heading when additional information on the topic
is covered on the page or pages that follow it.
bold Represents commands, command options, and syntax that
must be typed exactly as shown. It also indicates
commands on menus and buttons, dialog box titles and
options, and icon and menu names.
italic In syntax statements or descriptive text, indicates argument
names or placeholders for variable information.
Title Capitals Indicate d omain names, user names, computer names,
directory names, and folder and file names, except when
specifically referring to case-sensitive names. Unless
otherwise indicated, you can use lowercase letters when
you type a directory name or file name in a dialog box or
at a command prompt.
ALL CAPITALS Indicate the names of keys, key sequences, and key
combinations — for example, ALT+SPACEBAR.
monospace Represents code samples or examples of screen text.
[] In syntax statements, enclose optional items. For example,
[filename] in command syntax indicates that you can
choose to type a file name with the command. Type only
the information within the brackets, not the brackets
themselves.
{} In syntax statements, enclose required items. Type only the
information within the braces, not the braces themselves.
| In syntax statements, separates an either/or choice.
å Indicates a procedure with sequential steps.
... In syntax statements, specifies that the preceding item may
be repeated.
. Represents an omitted portion of a code sample.
.
.
THIS PAGE INTENTIONALLY LEFT BLANK