ebook img

Introduction to C# Programming for the Microsoft® .NET Platform PDF

812 Pages·2001·12.989 MB·English
by  
Save to my drive
Quick download
Download
Most books are stored in the elastic cloud where traffic is expensive. For this reason, we have a limit on daily download.

Preview Introduction to C# Programming for the Microsoft® .NET Platform

Introduction to C# Programming for the Microsoft .NET Platform ® (Prerelease) Workbook C ourse 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. Part Number: X08-16666 Released: 03/2001 Information in this document is subject to change without notice. The names of companies, products, people, characters, and/or data mentioned herein are fictitious and are in no way intended to represent any real individual, company, product, or event, unless otherwise noted. Complying with all applicable copyright laws is the responsibility of the user. No part of this document may be reproduced or transmitted in any form or by any means, electronic or mechanical, for any purpose, without the express written permission of Microsoft Corporation. If, however, your only means of access is electronic, permission to print one copy is hereby granted. 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. (cid:211) 2001 Microsoft Corporation. All rights reserved. Microsoft, ActiveX, BackOffice, BizTalk, IntelliSense, JScript, MSDN, MS-DOS, PowerPoint, Visual Basic, Visual C++, Visual C#, Visual Studio, Windows, Windows NT, and Windows Media are either registered trademarks or trademarks of Microsoft Corporation in the U.S.A. and/or other countries. Other product and company names mentioned herein may be the trademarks of their respective owners. Course Number: 2124A Part Number: X08-16666 Released: 03/2001 Introduction to C# Programming for the Microsoft®. NET Platform (Prerelease) iii 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) Lab 4.2: Using Exceptions..........................................................................62 Review.....................................................................................................72 Module 5: Methods and Parameters Overview....................................................................................................1 Using Methods............................................................................................2 Using Parameters.......................................................................................16 Using Overloaded Methods.........................................................................30 Lab 5: Creating and Using Methods.............................................................38 Review.....................................................................................................50 Module 6: Arrays Overview....................................................................................................1 Overview of Arrays......................................................................................2 Creating Arrays.........................................................................................11 Using Arrays.............................................................................................18 Lab 6: Creating and Using Arrays................................................................31 Review.....................................................................................................42 Module 7: Essentials of Object-Oriented Programming Overview....................................................................................................1 Classes and Objects......................................................................................2 Using Encapsulation...................................................................................10 C# and Object Orientation...........................................................................21 Lab 7: Creating and Using Classes...............................................................39 Defining Object-Oriented Systems...............................................................53 Review.....................................................................................................62 Module 8: Using Reference-Type Variables Overview....................................................................................................1 Using Reference-Type Variables....................................................................2 Using Common Reference Types.................................................................15 The Object Hierarchy.................................................................................23 Namespaces in the .NET Framework............................................................29 Lab 8.1: Defining And Using Reference-Type Variables.................................35 Data Conversions.......................................................................................43 Multimedia: Type-Safe Casting...................................................................56 Lab 8.2 Converting Data.............................................................................57 Review.....................................................................................................63 Module 9: Creating and Destroying Objects Overview....................................................................................................1 Using Constructors......................................................................................2 Initializing Data.........................................................................................13 Lab 9.1: Creating Objects...........................................................................31 Objects and Memory..................................................................................39 Using Destructors......................................................................................45 Lab 9.2: Destroying Objects........................................................................60 Review.....................................................................................................65 Module 10: Inheritance in C# Overview....................................................................................................1 Deriving Classes..........................................................................................2 Implementing Methods...............................................................................10 Introduction to C# Programming for the Microsoft®.N ET Platform (Prerelease) v Using Sealed Classes..................................................................................26 Using Interfaces.........................................................................................28 Using Abstract Classes...............................................................................42 Lab 10: Using Inheritance to Implement an Interface......................................53 Review.....................................................................................................71 Module 11: Aggregation, Namespaces, and Advanced Scope Overview....................................................................................................1 Using Internal Classes, Methods, and Data......................................................2 Using Aggregation.....................................................................................11 Lab 11.1: Specifying Internal Access............................................................22 Using Namespaces.....................................................................................28 Using Modules and Assemblies...................................................................49 Lab 11.2: Using Namespaces and Assemblies................................................63 Review.....................................................................................................69 Module 12: Operators, Delegates, and Events Overview....................................................................................................1 Introduction to Operators..............................................................................2 Operator Overloading...................................................................................8 Lab 12.1: Defining Operators......................................................................21 Creating and Using Delegates......................................................................40 Defining and Using Events..........................................................................50 Demonstration: Handling Events..................................................................56 Lab 12.2: Defining and Using Events...........................................................57 Module 13: Properties and Indexers Overview....................................................................................................1 Using Properties ..........................................................................................2 Using Indexers..........................................................................................17 Lab 13: Using Properties and Indexers..........................................................33 Review.....................................................................................................42 Module 14: Attributes Overview....................................................................................................1 Overview of Attributes.................................................................................2 Defining Custom Attributes.........................................................................13 Retrieving Attribute Values.........................................................................22 Lab 14: Defining and Using Attributes .........................................................26 Review.....................................................................................................34 Appendix A: Resources for Further Study Resources for C#.........................................................................................1 Introduction to C# Programming for the Microsoft®. NET Platform (Prerelease) vii About This Course This section provides you with a brief description of the course, audience, suggested prerequisites, and course objectives. 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 Framework 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 Student Materials Compact Disc Contents The Student Materials compact disc contains the following files and folders: n 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 CD or install Internet Explorer. n Default.htm. This file opens the Student Materials Web page. It provides you with resources pertaining to this course, including additional reading, review and lab answers, lab files, multimedia presentations, and course- related Web sites. n Readme.txt. This file contains a description of the compact disc contents and setup instructions in ASCII format (non-Microsoft Word document). n 2124a_sg.doc. This file is the Classroom Setup Guide. It contains a description of classroom requirements, classroom setup instructions, and the classroom configuration. n AddRead. This folder contains additional reading pertaining to this course. If there are no additional reading files, this folder does not appear. n Appendix. This folder contains appendix files for this course. If there are no appendix files, this folder does not appear. n Democode. This folder contains demonstration code. If there is no demonstration code, the Democode folder does not appear. n Fonts. This folder contains fonts that are required to view the PowerPoint presentation and Web-based materials. n Ie5. This folder contains Microsoft Internet Explorer 5.5. n 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. n Media. This folder contains files that are used in multimedia presentations for this course. If this course does not include any multimedia presentations, this folder does not appear. n Menu. This folder contains elements for autorun.exe. n Mplayer. This folder contains files that are required to install Windows Media Player. n Practices. This folder contains files that are used in the hands-on practices. If there are no practices, the Practices folder does not appear. n Sampapps. This folder contains the sample applications associated with this course. If there are no associated sample applications, the Sampapps folder does not appear. n Sampcode. This folder contains sample code that is accessible through the Web pages on the Student Materials CD. If there is no sample code, the Sampcode folder does not appear. n Sampsite. This folder contains files that create the sample site associated with this course. If there is no sample site, the Sampsite folder does not appear. n Setup. This folder contains additional files that may be required for lab setup. If no additional files are required, the Setup folder does not appear. x Introduction to C# Programming for the Microsoft® .NET Platform (Prerelease) 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.

See more

The list of books you might like

Most books are stored in the elastic cloud where traffic is expensive. For this reason, we have a limit on daily download.