0% found this document useful (0 votes)
3 views

Ms 10266a Programming In C With Visual Studio 2010 Vol 1 Student Manual download

The document provides an overview of the MS 10266A Programming in C# with Visual Studio 2010 course, detailing its modules and lessons focused on C# programming and the .NET Framework. It includes links to related resources and recommended products for further learning. The content emphasizes practical application development skills, debugging, and using various programming constructs within Visual Studio 2010.

Uploaded by

labaroliurdc
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
3 views

Ms 10266a Programming In C With Visual Studio 2010 Vol 1 Student Manual download

The document provides an overview of the MS 10266A Programming in C# with Visual Studio 2010 course, detailing its modules and lessons focused on C# programming and the .NET Framework. It includes links to related resources and recommended products for further learning. The content emphasizes practical application development skills, debugging, and using various programming constructs within Visual Studio 2010.

Uploaded by

labaroliurdc
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 70

Ms 10266a Programming In C With Visual Studio

2010 Vol 1 Student Manual download

https://ebookbell.com/product/ms-10266a-programming-in-c-with-
visual-studio-2010-vol-1-student-manual-2581036

Explore and download more ebooks at ebookbell.com


Here are some recommended products that we believe you will be
interested in. You can click the link to download.

Ms Course 10266a Programming In C With Microsoft Visual Studio 2010


Trainer Edition Volume 1 Microsoft

https://ebookbell.com/product/ms-course-10266a-programming-in-c-with-
microsoft-visual-studio-2010-trainer-edition-
volume-1-microsoft-2113632

Ms Course 10266a Programming In C With Microsoft Visual Studio 2010


Trainer Edition Volume 2 Microsoft

https://ebookbell.com/product/ms-course-10266a-programming-in-c-with-
microsoft-visual-studio-2010-trainer-edition-
volume-2-microsoft-2113634

Ms Fortune Drive Me Wild 1 Amy Booker

https://ebookbell.com/product/ms-fortune-drive-me-wild-1-amy-
booker-45697342

Chinas Approach Towards Territorial Disputes Lessons And Prospects


Lessons And Prospects Ms Sana Hashmi

https://ebookbell.com/product/chinas-approach-towards-territorial-
disputes-lessons-and-prospects-lessons-and-prospects-ms-sana-
hashmi-46090702
Ms Calculation Danica Winters

https://ebookbell.com/product/ms-calculation-danica-winters-46134978

Ms Demeanor Danica Winters

https://ebookbell.com/product/ms-demeanor-danica-winters-46134984

Ms Excel Lets Advance To The Next Level 2nd Edition Anurag Singal

https://ebookbell.com/product/ms-excel-lets-advance-to-the-next-
level-2nd-edition-anurag-singal-46413368

Ms900 Microsoft 365 Fundamentals Exam Cram Notes First Edition 2022 Ip
Specialist

https://ebookbell.com/product/ms900-microsoft-365-fundamentals-exam-
cram-notes-first-edition-2022-ip-specialist-47649480

Zx Quantumpy A Beginners Guide To Quantum Computing And Zxcalculus


Using Pyzx Ms Mahnoor Fatima

https://ebookbell.com/product/zx-quantumpy-a-beginners-guide-to-
quantum-computing-and-zxcalculus-using-pyzx-ms-mahnoor-fatima-49159236
OFFICIAL MICROSOFT LEARNING PRODUCT

10266A
Programming in C# with
Microsoft® Visual Studio® 2010

Be sure to access the extended learning content on your Course


Companion CD enclosed on the back cover of the book.
ii Programming in C# with Microsoft® Visual Studio® 2010

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, place or event 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.

The names of manufacturers, products, or URLs are provided for informational purposes only and
Microsoft makes no representations and warranties, either expressed, implied, or statutory,
regarding these manufacturers or the use of the products with any Microsoft technologies. The
inclusion of a manufacturer or product does not imply endorsement of Microsoft of the
manufacturer or product. Links may be provided to third party sites. Such sites are not under the
control of Microsoft and Microsoft is not responsible for the contents of any linked site or any link
contained in a linked site, or any changes or updates to such sites. Microsoft is not responsible for
webcasting or any other form of transmission received from any linked site. Microsoft is providing
these links to you only as a convenience, and the inclusion of any link does not imply endorsement
of Microsoft of the site or the products contained therein.
© 2010 Microsoft Corporation. All rights reserved.

Microsoft, and Windows are either registered trademarks or trademarks of Microsoft Corporation in
the United States and/or other countries.
All other trademarks are property of their respective owners.

Product Number: 10266A

Part Number: 01918

Released: 09/2010
Programming in C# with Microsoft® Visual Studio® 2010 v

Contents
Module 1: Introducing C# and the .NET Framework
Lesson 1: Introduction to the .NET Framework 4 1-4
Lesson 2: Creating Projects Within Visual Studio 2010 1-16
Lesson 3: Writing a C# Application 1-33
Lesson 4: Building a Graphical Application 1-44
Lesson 5: Documenting an Application 1-58
Lesson 6: Debugging Applications by Using Visual Studio 2010 1-66
Lab: Introducing C# and the .NET Framework 1-78

Module 2: Using C# Programming Constructs


Lesson 1: Declaring Variables and Assigning Values 2-4
Lesson 2: Using Expressions and Operators 2-23
Lesson 3: Creating and Using Arrays 2-36
Lesson 4: Using Decision Statements 2-49
Lesson 5: Using Iteration Statements 2-63
Lab: Using C# Programming Constructs 2-78

Module 3: Declaring and Calling Methods


Lesson 1: Defining and Invoking Methods 3-3
Lesson 2: Specifying Optional Parameters and Output Parameters 3-29
Lab: Declaring and Calling Methods 3-39

Module 4: Handling Exceptions


Lesson 1: Handling Exceptions 4-3
Lesson 2: Raising Exceptions 4-23
Lab: Handling Exceptions 4-34
vi Programming in C# with Microsoft® Visual Studio® 2010

Module 5: Reading and Writing Files


Lesson 1: Accessing the File System 5-3
Lesson 2: Reading and Writing Files by Using Streams 5-27
Lab: Reading and Writing Files 5-45

Module 6: Creating New Types


Lesson 1: Creating and Using Enumerations 6-3
Lesson 2: Creating and Using Classes 6-12
Lesson 3: Creating and Using Structures 6-33
Lesson 4: Comparing References to Values 6-41
Lab: Creating New Types 6-55

Module 7: Encapsulating Data and Methods


Lesson 1: Controlling Visibility of Type Members 7-4
Lesson 2: Sharing Methods and Data 7-15
Lab: Encapsulating Data and Methods 7-29

Module 8: Inheriting from Classes and Implementing Interfaces


Lesson 1: Using Inheritance to Define New Reference Types 8-3
Lesson 2: Defining and Implementing Interfaces 8-27
Lesson 3: Defining Abstract Classes 8-45
Lab: Inheriting from Classes and Implementing Interfaces 8-56

Module 9: Managing the Lifetime of Objects and Controlling Resources


Lesson 1: Introduction to Garbage Collection 9-4
Lesson 2: Managing Resources 9-21
Lab: Managing the Lifetime of Objects and Controlling Resources 9-35

Module 10: Encapsulating Data and Defining Overloaded Operators


Lesson 1: Creating and Using Properties 10-4
Lab A: Creating and Using Properties 10-26
Lesson 2: Creating and Using Indexers 10-38
Lab B: Creating and Using Indexers 10-50
Programming in C# with Microsoft® Visual Studio® 2010 vii

Lesson 3: Overloading Operators 10-60


Lab C: Overloading Operators 10-79

Module 11: Decoupling Methods and Handling Events


Lesson 1: Declaring and Using Delegates 11-4
Lesson 2: Using Lambda Expressions 11-14
Lesson 3: Handling Events 11-22
Lab: Decoupling Methods and Handling Events 11-38

Module 12: Using Collections and Building Generic Types


Lesson 1: Using Collections 12-4
Lab A: Using Collections 12-22
Lesson 2: Creating and Using Generic Types 12-28
Lesson 3: Defining Generic Interfaces and Understanding Variance 12-42
Lesson 4: Using Generic Methods and Delegates 12-56
Lab B: Building Generic Types 12-69

Module 13: Building and Enumerating Custom Collection Classes


Lesson 1: Implementing a Custom Collection Class 13-3
Lesson 2: Adding an Enumerator to a Custom Collection Class 13-21
Lab: Building and Enumerating Custom Collection Classes 13-37

Module 14: Using LINQ to Query Data


Lesson 1: Using the LINQ Extension Methods and Query Operators 14-3
Lesson 2: Building Dynamic LINQ Queries and Expressions 14-28
Lab: Using LINQ to Query Data 14-47

Module 15: Integrating Visual C# Code with Dynamic Languages and COM
Components
Lesson 1: Integrating Visual C# Code with Ruby and Python 15-4
Lesson 2: Accessing COM Components from Visual C# 15-19
Lab: Integrating Visual C# Code with Dynamic Languages and COM
Components 15-36
viii Programming in C# with Microsoft® Visual Studio® 2010

Appendix: Lab Answer Keys


Module 1 Lab: Introducing C# and the .NET Framework L1-1
Module 2 Lab: Using C# Programming Constructs L2-1
Module 3 Lab: Declaring and Calling Methods L3-1
Module 4 Lab: Handling Exceptions L4-1
Module 5 Lab: Reading and Writing Files L5-1
Module 6 Lab: Creating New Types L6-1
Module 7 Lab: Encapsulating Data and Methods L7-1
Module 8 Lab: Inheriting from Classes and Implementing Interfaces L8-1
Module 9 Lab: Managing the Lifetime of Objects and Controlling
Resources L9-1
Module 10 Lab A: Creating and Using Properties L10A-1
Module 10 Lab B: Creating and Using Indexers L10B-1
Module 10 Lab C: Overloading Operators L10C-1
Module 11 Lab: Decoupling Methods and Handling Events L11-1
Module 12 Lab A: Using Collections L12A-1
Module 12 Lab B: Building Generic Types L12B-1
Module 13 Lab: Building and Enumerating Custom Collection Classes L13-1
Module 14 Lab: Using LINQ to Query Data L14-1
Module 15 Lab: Integrating Visual C# Code with Dynamic Languages
and COM Components L15-1
Introducing C# and the .NET Framework 1-1

Module 1
Introducing C# and the .NET Framework
Contents:
Lesson 1: Introduction to the .NET Framework 4 1-4
Lesson 2: Creating Projects Within Visual Studio 2010 1-16
Lesson 3: Writing a C# Application 1-33
Lesson 4: Building a Graphical Application 1-44
Lesson 5: Documenting an Application 1-58
Lesson 6: Debugging Applications by Using Visual Studio 2010 1-66
Lab: Introducing C# and the .NET Framework 1-78
1-2 Programming in C# with Microsoft® .Visual Studio® 2010

Module Overview

Microsoft® Visual Studio® 2010 and the Microsoft .NET Framework 4 provide a
comprehensive development platform to enable you to build, debug, deploy, and
manage applications.
This module describes the purpose of the .NET Framework 4, and how to build
applications by using Visual Studio 2010.

Objectives
After completing this module, you will be able to:
• Explain the purpose of the .NET Framework 4.
• Create Microsoft Visual C#® projects by using Visual Studio 2010.
• Explain the structure of a Visual C# application.
• Use the Windows® Presentation Foundation (WPF) Application template to
build a simple graphical application.
Introducing C# and the .NET Framework 1-3

• Use XML comments to document an application.


• Use the debugger to step through a program.
1-4 Programming in C# with Microsoft® .Visual Studio® 2010

Lesson 1
Introduction to the .NET Framework 4

This lesson introduces the .NET Framework 4, and describes the key concepts of
.NET and some of the tools that are provided to help simplify development.

Objectives
After completing this lesson, you will be able to:

• Describe the purpose of the .NET Framework 4.


• Describe the role of Visual C# for writing the code for .NET Framework 4
applications.
• Describe the purpose of an assembly.
• Explain how the common language runtime (CLR) compiles and runs
assemblies.
• Describe the tools that the .NET Framework 4 provides.
Introducing C# and the .NET Framework 1-5

What Is the .NET Framework 4?

Key Points
The .NET Framework 4 provides a comprehensive development platform that
offers a fast and efficient way to build applications and services. Using Visual
Studio 2010, developers can utilize the .NET Framework 4 to create a wide range
of solutions that operate across a broad range of computing devices.
The .NET Framework 4 provides three principal elements: the CLR, the .NET
Framework class library, and a collection of development frameworks.

The Common Language Runtime


The .NET Framework 4 provides an environment called the CLR. The CLR
manages the execution of code and simplifies the development process by
providing a robust and secure execution environment that provides common
services such as memory management, transactions, interprocess communications,
multithreading, and many other features.
1-6 Programming in C# with Microsoft® .Visual Studio® 2010

The .NET Framework Class Library


The .NET Framework 4 provides a library of reusable classes that developers can
use to build applications. The classes provide a foundation of common
functionality and constructs that help simplify application development and
remove the requirement for developers to constantly reinvent logic. For example,
the System.IO.File class contains functionality that enables developers to
manipulate files on the Windows file system. In addition to using the classes in the
.NET Framework class library, you can extend these classes by creating your own
libraries of classes.

Development Frameworks
The .NET Framework 4 provides several development frameworks that you can
use to build common types of applications. These frameworks provide the
necessary components and infrastructure to get you started. The development
frameworks include:
• ASP.NET. Enables you to build server-side Web applications.
• WPF. Enables you to build rich client applications.
• Windows Communication Foundation (WCF). Enables you to build secure and
reliable service-oriented applications.
• Windows Workflow Foundation (WF). Enables you to build workflow solutions
to fulfill the complex business requirements of modern organizations.

Question: What is the purpose of the .NET Framework 4, and the three main
components that it provides?

Additional Reading
For more information about the .NET Framework, see the Microsoft .NET page at
http://go.microsoft.com/fwlink/?LinkId=192876.
Introducing C# and the .NET Framework 1-7

The Purpose of Visual C#

Key Points
The CLR runs executable code that is generated by using a compiler. You can build
applications for the .NET Framework by using any language that has a compiler
that can generate executable code in the format that the CLR recognizes. Visual
Studio 2010 provides compilers for C++, Visual Basic, F#, and C#. Compilers for
other languages are available from a variety of third-party vendors.
C# is the language of choice for many developers. It uses a syntax that is very
similar to C, C++, and Java, and has several extensions and features that are
designed for operation with the .NET Framework. Because of its heritage, many
developers who are familiar with other programming languages find C# easy to
learn and can be productive very quickly.
The C# language has been standardized and is described by the ECMA-334 C#
Language Specification. Several vendors apart from Microsoft produce C#
compilers. The Microsoft implementation is called Visual C#, and is integrated into
Visual Studio. Visual Studio supports Visual C# with a full-featured code editor,
compiler, project templates, designers, code wizards, a powerful and easy-to-use
debugger, and other tools. C# is also available from Microsoft as Visual C# Express
1-8 Programming in C# with Microsoft® .Visual Studio® 2010

Edition, which provides a subset of the features that are provided with Visual
Studio.

Note: C# is an evolving language. Visual C# 2010 uses C# 4.0, which contains several
extensions to the C# language that are not yet part of the ECMA standard.

Question: Which programming languages have you used?

Additional Reading
For more information about the Microsoft implementation of Visual C# 2010, see
the Visual C# page http://go.microsoft.com/fwlink/?LinkId=192877.
For more information about the new features of C# 4.0, see the What's New in
Visual C# 2010 page at http://go.microsoft.com/fwlink/?LinkId=192878.
Introducing C# and the .NET Framework 1-9

What Is an Assembly?

Key Points
When you compile a Visual C# application by using Visual Studio 2010, the
compiler generates an executable file that the CLR can run. This file is called an
assembly. An assembly contains code in an intermediate format called Microsoft
intermediate language (MSIL). All compilers for the .NET Framework generate
code in this format, regardless of the programming language that was used to write
an application. This enables the CLR to run code in the same way, regardless of the
language that the developer used.
Assemblies are the building blocks of .NET Framework applications; they form the
fundamental unit of deployment, version control, reuse, and security.
You can think of an assembly as a collection of types and resources that work
together and form a logical unit of functionality. An assembly provides the CLR
with the information that it needs to be aware of type implementations.
An assembly can be of two types: an executable program, or a library that contains
executable code that other programs can reuse. By using a library, developers can
modularize the development of their applications into logical components.
1-10 Programming in C# with Microsoft® .Visual Studio® 2010

Typically, when you are distributing assemblies to customers as part of your


application, you will want to ensure that the assembly contains versioning
information, and that the assembly is signed.
Versioning your assemblies is important because ultimately, any applications that
you build will have multiple releases. Versioning information can help you identify
which versions customers already have and enable you to perform the necessary
steps to upgrade the application. Similarly versioning information can also help
when documenting and fixing bugs.
Signing your assemblies is equally important because it ensures that your assembly
cannot easily be modified or replaced by an alternative implementation from a
malicious source, and because it gives the assembly a strong name.
Information such as the assembly version and security identity is stored as
metadata in an assembly manifest. The manifest also contains metadata that
describes the scope of the assembly, and any references to classes and resources.
The manifest is typically stored in a portable executable (PE) file.

Assembly Versioning
Assembly version information is stored in the assembly manifest and is used with
the assembly name and culture to derive the assembly’s identity. An assembly
version number consists of the following:
• Major version number
• Minor version number
• Build number
• Revision number

Assembly Signing
Assembly signing is an important step that developers should include in their build
process because it provides the following benefits:
• It protects assemblies from modification.
• It enables you to include the signed assembly in the Global Assembly Cache
(GAC), so you can share the assembly with multiple applications.
• It guarantees that the name of the assembly is unique.
• To sign your assembly, you can use the Sign Tool that is provided with the
.NET Framework, or you can use the assembly-signing functionality in Visual
Studio 2010.
Introducing C# and the .NET Framework 1-11

Question: Why would you choose to distribute an assembly rather than distribute
the source code?

Additional Reading
For more information about the purpose and features of assemblies, see the
Assemblies in the Common Language Runtime page at
http://go.microsoft.com/fwlink/?LinkId=192879.
For more information about assembly versioning, see the Assembly Versioning
page at http://go.microsoft.com/fwlink/?LinkId=192880.
For more information about assembly signing, see the SignTool.exe (Sign Tool)
page at http://go.microsoft.com/fwlink/?LinkId=192881.
1-12 Programming in C# with Microsoft® .Visual Studio® 2010

How the Common Language Runtime Loads, Compiles, and


Runs Assemblies

Key Points
Assemblies contain MSIL code, which is not executable. When you run a .NET
Framework application, the CLR loads the MSIL code from an assembly and
converts it into the machine code that the computer requires.
The CLR is a fundamental component of the .NET Framework. It handles code
execution and provides useful services for application development. The CLR
contains several components that perform the following tasks when you run a
.NET Framework application:
1. The Class Loader locates and loads all assemblies that the application requires.
The assemblies will already be compiled into MSIL.
2. The MSIL-to-native compiler verifies the MSIL code and then compiles all
assemblies into machine code ready for execution.
Introducing C# and the .NET Framework 1-13

Note: The CLR performs the verification step because it is possible to write your own
MSIL code. If you use a C# compiler, the MSIL code will be valid, but the CLR cannot
make any assumptions.

3. The Code Manager loads the executable assembly and runs the Main method.
4. The Garbage Collector provides automatic lifetime memory management of all
objects that your application creates. The Garbage Collector disposes of any
objects that your application is no longer using.
5. The Exception Manager provides structured exception handling for .NET
applications, which is integrated with Windows structured exception
handling.

Question: What steps does the CLR perform when you run your application?
1-14 Programming in C# with Microsoft® .Visual Studio® 2010

What Tools Does the .NET Framework Provide?

Key Points
The .NET Framework provides several tools to help simplify the development of
.NET applications. The following table describes some of the key tools.

Tool Description

Code Access Security Policy Enables users to modify the machine, user, and
Tool (Caspol.exe) enterprise security policy. This can include defining
a custom permission set and adding assemblies to
the full trust list.

Certificate Creation Tool Enables users to create x.509 certificates for use in
(Makecert.exe) their development environment. Typically, you can
use these certificates to sign your assemblies and
define Secure Sockets Layer (SSL) connections.

Global Assembly Cache Tool Enables users to manipulate the assemblies in the
(Gacutil.exe) GAC. This can include installing and uninstalling
assemblies in the GAC so that multiple applications
can access them.
Introducing C# and the .NET Framework 1-15

Tool Description

Native Image Generator Enables users to improve the performance of .NET


(Ngen.exe) applications. The Native Image Generator improves
performance by precompiling assemblies into
images that contain processor-specific machine
code. The CLR can then run the precompiled
images instead of using just-in-time (JIT)
compilation. Alternatively, if you use JIT
compilation, your code is compiled just before it is
executed.

MSIL Disassembler (Ildasm.exe) Enables users to manipulate assemblies, such as


determining whether an assembly is managed, or
disassembling an assembly to view the compiled
MSIL code.

Strong Name Tool (Sn.exe) Enables users to sign assemblies with strong names.
The Strong Name Tool includes commands to
create a new key pair, extract a public key from a
key pair, and verify assemblies.

Question: You have created two applications that both use an assembly called
Contoso.ReportGenerator.dll. Both applications will run on the same machine.
What is the best approach to share the Contoso.ReportGenerator.dll assembly
and which tool would you use?

Additional Reading
For more information about the tools that the .NET Framework provides, see the
.NET Framework Tools page at http://go.microsoft.com/fwlink/?LinkId=192882.
1-16 Programming in C# with Microsoft® .Visual Studio® 2010

Lesson 2
Creating Projects Within Visual Studio 2010

This lesson introduces you to Visual Studio 2010 and describes how it can help
simplify the development of .NET applications through the use of predefined
application templates, and features of the integrated development environment
(IDE).

Objectives
After completing this lesson, you will be able to:
• Describe the features that are available in Visual Studio 2010 that aid
programming productivity.
• Describe the various project types that Visual Studio 2010 supports and when
to use them.
• Describe the primary files that are found in most Visual Studio solutions.
Introducing C# and the .NET Framework 1-17

• Explain how to create a console application by using the Console Application


template in Visual Studio 2010.
• Use Visual Studio to compile and run an application.
1-18 Programming in C# with Microsoft® .Visual Studio® 2010

Key Features of Visual Studio 2010

Key Points
Visual Studio 2010 presents a single development environment that enables you to
rapidly design, implement, build, test, and deploy various types of applications and
components by using a range of programming languages.
Some of the key features of Visual Studio 2010 are:

• Intuitive integrated development environment. The Visual Studio 2010 IDE


provides all of the features and tools that are necessary to design, implement,
build, test, and deploy applications and components.
• Rapid application development. Visual Studio 2010 provides design views for
graphical components that enable you to build complex user interfaces easily.
Alternatively, you can use the Code Editor views, which provide more control.
Visual Studio 2010 also provides wizards that help speed up the development
of particular components.
Introducing C# and the .NET Framework 1-19

• Server and data access. Visual Studio 2010 provides the Server Explorer, which
enables you to log on to servers and explore their databases and system
services. It provides a familiar way to create, access, and modify databases that
your application uses.
• Debugging features. Visual Studio 2010 provides a debugger, which enables you
to step through local or remote code, pause at breakpoints, and follow
execution paths.
• Error handling. Visual Studio 2010 provides the Error List window, which
displays any errors, warnings, or messages that are produced as you edit and
build your code.
• Help and documentation. Visual Studio 2010 also provides help and guidance
through Microsoft IntelliSense®, code snippets, and the integrated help system,
which contains documentation and samples.

Question: What are the main reasons why you may choose Visual Studio 2010
over a text editor such as Notepad++?
1-20 Programming in C# with Microsoft® .Visual Studio® 2010

Templates in Visual Studio 2010

Key Points
Visual Studio 2010 supports the development of different types of applications
such as Windows-based client applications, Web-based applications, services, and
libraries. To help you get started, Visual Studio 2010 provides several application
templates that provide a structure for the different types of applications. These
templates:

• Provide starter code that you can build on to quickly create a functioning
application.
• Include supporting components and controls that are relevant to the project
type.
• Configure the Visual Studio 2010 IDE to the type of application that you are
developing.
• Add references to any initial assemblies that this type of application usually
requires.
Introducing C# and the .NET Framework 1-21

Types of Templates
The following table describes some of the common application templates that you
can use when you develop .NET Framework applications by using Visual Studio
2010.

Template Description
Console Application Provides the environment settings, tools, project
references, and starter code to develop an application
that runs in a command-line interface. This type of
application is considered lightweight compared to the
Windows Forms application template because there is
no graphical user interface.

WPF Application Provides the environment settings, tools, project


references, and starter code to build a rich graphical
Windows application. A WPF application enables you
to create the next generation of Windows applications,
with much more control over user interface design.

Class Library Provides the environment settings, tools, and starter


code to build a .dll assembly. You can use this type of
file to store functionality that you might want to invoke
from many other applications.

Windows Forms Application Provides the environment settings, tools, project


references, and starter code to build a graphical
Windows Forms application.

ASP.NET Web Application Provides the environment settings, tools, project


references, and starter code to create a server-side,
compiled ASP.NET Web application.

ASP.NET MVC 2 Application Provides the environment settings, tools, project


references, and starter code to create a Model-View-
Controller (MVC) Web application. An ASP.NET MVC
Web application differs from the standard ASP.NET
Web application in that the application architecture
helps you separate the presentation layer, business
logic layer, and data access layer.

Silverlight Application Provides the environment settings, tools, project


references, and starter code to build a rich, graphical
Web application.
1-22 Programming in C# with Microsoft® .Visual Studio® 2010

Template Description

WCF Service Application Provides the environment settings, tools, project


references, and starter code to build Service Orientated
Architecture (SOA) services.

Question: What project templates would you use for each of the following:
• A client application that will run on a Windows-based computer.
• A library of functionality that you want to use in other applications.
• A Web site that you will host on an Internet Information Services (IIS) Web
server.
Introducing C# and the .NET Framework 1-23

The Structure of Visual Studio Projects and Solutions

Key Points
Visual Studio 2010 uses solutions and projects as conceptual containers to
organize your source files during development. Categorizing your source files in
this way simplifies the build and deployment process for your .NET Framework
applications.

Visual Studio Projects


A project is used to organize source files, references, and project-level configuration
settings that make up a single .NET Framework application or library. When you
create a project in Visual Studio, the project is automatically organized into a
solution.
The following table describes some of the common file types that you will find in a
Visual Studio project.
1-24 Programming in C# with Microsoft® .Visual Studio® 2010

File Description

.cs Code files that can belong to a single project solution. This type of file
can represent any of the following:
• Modules
• Windows Forms files
• Class files
.csproj Project files that can belong to multiple project solutions. The .csproj
file also stores settings for the project, such as the output path for the
build output and the target platform.

.aspx Files that represent ASP.NET Web pages. An ASP.NET file can contain
your Visual C# code or you can use an accompanying .aspx.cs file to
store your code in addition to the page markup.

.config Configuration files are XML-based files that you can use to store
application-level settings such as database connection strings, which
you can then modify without recompiling your application.

.xaml XAML files are used in WPF and Microsoft Silverlight® applications to
define user interface elements.

Visual Studio Solutions


A single Visual Studio solution is a container for one or more projects. By default,
when you create a new project, Visual Studio automatically creates a solution for
the project. You can add additional projects to a solution. This is useful if, for
example, you are building a library assembly and an application that tests this
library. You can build and compile both projects as part of the same solution rather
than having to run multiple instances of Visual Studio.
A solution can also contain project-independent items that any of the projects in
the solution can use. For example, an ASP.NET solution can contain a single
cascading style sheet (.css) file that applies a standard look and feel to any of the
included ASP.NET projects.
Categorizing multiple projects into a single Visual Studio solution provides the
following advantages:

• It enables you to work on multiple projects within a single Visual Studio 2010
session.
• It enables you to apply configuration settings globally to multiple projects.
Introducing C# and the .NET Framework 1-25

• It enables you to deploy multiple projects within a single solution.

The following table describes the solution definition files.

File Description

.sln A Visual Studio 2010 solution file that provides a single point of access to
multiple projects, project items, and solution items. The .sln file is a
standard text file, but it is not recommended to change it outside Visual
Studio 2010.

.suo A solution user options file that stores any settings that you have changed
to customize the Visual Studio 2010 IDE.

Question: What role does the .sln file play in Visual Studio solutions?
1-26 Programming in C# with Microsoft® .Visual Studio® 2010

Creating a .NET Framework Application

Key Points
The application templates that Visual Studio 2010 provides enable you to start
creating an application with minimal effort. You can then add your code and
customize the project to meet your own requirements.
The following steps describe how to create a console application.

X Create a new console project by using the Console Application


template in Visual Studio 2010
1. Open Visual Studio 2010.

2. On the File menu, point to New, and then click Project.

3. In the New Project dialog box, specify the following settings for the project,
and then click OK:
a. In the Installed Templates list, under Visual C#, click Windows.
b. In the center pane, click Console Application.
Introducing C# and the .NET Framework 1-27

c. In the Name box, specify a name for the project.


d. In the Location box, specify the path where you want to save the
project.

Programmer Productivity Features


Visual Studio 2010 provides a host of features that can help you to write code.
When writing code, developers need to recall information about many program
elements. Instead of manually looking up information by searching help files or
other source code, the IntelliSense feature in Visual Studio provides the
information that developers need directly from the editor. IntelliSense provides the
following features:
• Quick Info. The Quick Info option displays the complete declaration for any
identifier in your code. Move the mouse so that the cursor rests on an
identifier to display Quick Info for that identifier, which appears in a yellow
pop-up box.
• Complete Word. The Complete Word option types the rest of a variable,
command, or function name after you have entered enough characters to
disambiguate the term. Type the first few letters of the name and then press
ALT+RIGHT ARROW or CTRL+SPACEBAR to complete the word.

Often, when you are building a .NET Framework application, you will need to
repeat common constructs in your code. Examples might be a loop, or code to
handle exceptions. Code snippets are designed to ease the burden of having to
implement such common code by providing boilerplate code templates that can be
readily inserted into your code and amended to suit your needs. You can access
these code snippets by using the Code Snippet Picker.
You can manage code snippets by using the Code Snippet Manager dialog box,
which is available on the Tools menu. The Code Snippet Manager enables you to
add new code snippets by specifying new folders that the Code Snippet Picker will
look in for code snippets; by importing code snippets; or by searching for code
snippets online. The Code Snippets Manager is also useful for discovering the
shortcut key sequence that is associated with a code snippet.
Finally, Visual Studio 2010 provides a host of other features on the shortcut menu
that appears when you right-click a code statement. These include Refactor,
Organize, Create Unit Tests, Go To Definition, Find All References, and Outline.
These features will be covered in more detail in later modules.
1-28 Programming in C# with Microsoft® .Visual Studio® 2010

Question: What is the purpose of code snippets?


Introducing C# and the .NET Framework 1-29

Building and Running a .NET Framework Application

Key Points
Visual Studio provides an integrated environment that enables you to quickly
compile and run your applications.
You can also build and run an application from the command line if you do not
have Visual Studio available.
The following steps describe how to build and run an application.

X Build and run an application in Visual Studio 2010


The following steps assume that you have created a new console application.

1. In Visual Studio 2010, on the Build menu, click Build Solution.

2. On the Debug menu, click Start Debugging.


1-30 Programming in C# with Microsoft® .Visual Studio® 2010

X Build an application from the command line


The following steps assume that you have created a new console application called
MyProject, which is saved in the C:\Users\Student\Documents
\Visual Studio 2010\MyProject\ folder.

1. Click Start, point to All Programs, click Microsoft Visual Studio 2010, click
Visual Studio Tools, and then click Visual Studio Command Prompt
(2010).

2. In the Visual Studio Command Prompt window, type the text in the following
code example, and then press ENTER.

csc.exe /t:exe /out:"C:\Users\Student\Documents\Visual Studio


2010\MyProject\myApplication.exe" "C:\Users\Student\Documents\Visual
Studio 2010\MyProject\*.cs"

3. Right-click the Start menu, click Open Windows Explorer, and then move to
C:\Users\Student\Documents\Visual Studio 2010\MyProject\.
The MyProject folder should now contain the myApplication.exe executable
assembly, which you can run.

Question: Describe two ways to build and run a .NET Framework application.
Introducing C# and the .NET Framework 1-31

Demonstration: Disassembling a .NET Framework Assembly

Key Points
• Run an existing .NET Framework application.
• Open Ildasm.
• Disassemble an existing .NET Framework assembly.
• Examine the disassembled .NET Framework assembly.

Demonstration Steps
1. Log on to the 10266A-GEN-DEV virtual machine as Student with the
password Pa$$word.
2. Run MyFirstApplication.exe in the E:\Demofiles\Mod1\Demo1 folder, and
examine the applications output.
3. Close MyFirstApplication.exe.
4. Run ildasm.exe in the C:\Program Files\Microsoft SDKs
\Windows\v7.0A\bin folder.
1-32 Programming in C# with Microsoft® .Visual Studio® 2010

5. Using ildasm, open the MyFirstApplication.exe in the


E:\Demofiles\Mod1\Demo1 folder, and then inspect the contents of the
MyFirstApplication assembly. Examine the following items:
• The public key token and the version number in the assembly Manifest.
• The constructor and Main method in the MyFirstApplication.Program
node.
6. Close ildasm.exe.

Question: When developing a .NET Framework application, how would you find
Ildasm useful?
Introducing C# and the .NET Framework 1-33

Lesson 3
Writing a C# Application

This lesson describes the structure of a simple C# application, and how a C#


application contains one or more classes. This lesson describes how to reference
functionality that is defined in classes in other assembles and libraries, and how
you can use the Console class in the .NET Framework class library to perform
simple input and output operations. Finally, this lesson explains how and why you
should add comments to your applications.

Objectives
After completing this lesson, you will be able to:
• Describe how Visual C# uses namespaces and classes.
• Describe the structure of an application.
• Perform input and output operations by using methods that the Console class
provides.
• Apply best practices commenting a Visual C# application.
1-34 Programming in C# with Microsoft® .Visual Studio® 2010

What Are Classes and Namespaces?

Key Points
Visual C# is an object-oriented language that uses classes and namespaces to
modularize .NET Framework applications into logical components.
A class is essentially a blueprint that defines the characteristics of an entity, and
includes properties that define the types of data that the object can contain and
methods that describe the behavior of the object. A namespace represents a logical
collection of classes. Classes are stored in assemblies, and a namespace is simply a
device to disambiguate classes that might have the same name in different
assemblies.
For example, the System.IO namespace includes the following classes that enable
you to manipulate the Windows file system. However, you could create classes
with the same name under your own namespace:
• File
• FileInfo
• Directory
Introducing C# and the .NET Framework 1-35

• DirectoryInfo
• Path

To use a class that is defined in the .NET Framework, perform the following tasks:
1. Add a reference to the assembly that contains the compiled code for the class.
2. Bring the namespace that contains the class into scope.

If you are writing a .NET Framework application to write text to a new file on the
file system, you can bring the System.IO namespace into scope and then use the
WriteAllText method of the File class.
To bring a namespace into scope in a Visual C# application, you can use the using
statement. The following code example shows how to bring the System,
System.IO, and System.Collections namespaces into scope.

using System;
using System.IO;
using System.Collections;

The using statement is simply a convenience and you can manage without it. For
example, you can use System.Console rather than Console.

Question: In your console application, you want to use the Console class, which
is part of the System namespace. How do you bring the System namespace into
scope?
1-36 Programming in C# with Microsoft® .Visual Studio® 2010

The Structure of a Console Application

Key Points
When you create a new console application by using the Console Application
template, Visual Studio 2010 performs the following tasks:
• It creates a new .csproj file to represent the console project and structure all of
the default components in a console project.
• It adds references to the assemblies in the .NET Framework class library that
console applications most commonly require. This set of assemblies includes
the System assembly.
• It creates the Program.cs file with a Main method, which provides an entry
point into the console application.

The Program.cs file that Visual Studio 2010 creates resembles the following code
example.
Introducing C# and the .NET Framework 1-37

using System;

namespace MyFirstApplication
{
class Program
{
static void Main(string[] args)
{

}
}
}

The following table describes the code items in the Program.cs file.

Code item Description

using System; Brings the System namespace into


scope.

namespace MyFirstApplication Defines a new namespace called


{ MyFirstApplication. Typically, in a new
... project, this defaults to the project
} name.

class Program Defines a new internal class called


{ Program.
...
}

static void Main(string[] args) Defines a new private static Main


{ method with a void return type that
... accepts a parameter of type string array.
}

What Is the Main Method?


Every .NET Framework application that compiles into an executable file must have
a Main method. This method provides the CLR with an entry point into the
application. When you run a .NET Framework application, the Main method is the
first method that the CLR executes.
1-38 Programming in C# with Microsoft® .Visual Studio® 2010

When you develop your .NET Framework applications, it is good practice to keep
the Main method lightweight, and let it serve as just an entry point, not a container
for most of the logic in your application.
The Main method has the following significant characteristics:
• It is private. This means that it is not visible to other classes outside the
Program class.
• It uses the static key, so it can be called without creating an instance of the
Program class.
• It uses the void return type, so it is a method that does not return data.
• It accepts data in the form of a string array. Therefore, when you run the
console application, any command-line arguments that you provide will be
available in the args parameter.

Question: In your console application, you have a method called Main. What is
the purpose of the Main method?

Additional Reading
For more information about command-line arguments, see the Main() and
Command-Line Arguments (C# Programming Guide) page at
http://go.microsoft.com/fwlink/?LinkId=192889.
Introducing C# and the .NET Framework 1-39

Performing Input and Output by Using a Console


Application

Key Points
The System namespace provides the Console class, which contains several
methods that enable you to add basic console I/O functionality to an application,
such as accepting input and displaying data.
The following table describes some of the key methods that the Console class
provides.

Method Description
Clear() Clears the console window and console buffer of any data. The
following code example provides an example of this.
using System;
...
Console.Clear(); // clears the console display
1-40 Programming in C# with Microsoft® .Visual Studio® 2010

Method Description

Read() Reads the next character from the console window. The following
code example provides an example of this.
using System;
...
int nextCharacter = Console.Read();

ReadKey() Reads the next character or key press from the console window.
The following code example provides an example of this.
using System;
...
ConsoleKeyInfo key = Console.ReadKey();

ReadLine() Reads the next line of characters from the console window. The
following code example provides an example of this.
using System;
...
string line = Console.ReadLine();

Write() Writes the text to the console window. The following code
example provides an example of this.
using System;
...
Console.Write("Hello there!");

WriteLine() Writes the text followed by a line break to the console window.
The following code example provides an example of this.
using System;
...
Console.WriteLine("Hello there!");

Question: Which two methods would you use to do the following:


• Display the message "Please press any key" on a new line.
• Capture the key that the user pressed.
Introducing C# and the .NET Framework 1-41

Additional Reading
For more information about the Console class, see the Console Class page at
http://go.microsoft.com/fwlink/?LinkId=192883.
1-42 Programming in C# with Microsoft® .Visual Studio® 2010

Best Practices for Commenting C# Applications

Key Points
It is good programming practice to begin all procedures with a brief comment that
describes the functional characteristics of the procedure. This is for your own
benefit and the benefit of anyone else who examines the code.
In Visual C#, comments begin with two slash marks (//). Comments can follow a
statement on the same line, or occupy an entire line. Both are illustrated in the
following code example.

// This is a comment on a separate line.


string message = "Hello there!"; // This is an inline comment.

The Comment and Uncomment Toolbar Buttons


You can add or remove comment symbols for a block of code by selecting the lines
of code and choosing the Comment or Uncomment buttons on the Text Editor
toolbar.
Introducing C# and the .NET Framework 1-43

Commenting Guidelines
As your code becomes more complex, use comments to make your code more
readable and easier to maintain. You should use comments to explain the purpose
of a section of code in natural language, especially when the purpose might not be
obvious or clear.
The following list provides some guidelines regarding when you should comment
your code:
• Begin procedures with a comment block. This block should include
information such as the purpose of the procedure, the value returned, the
arguments, and so on.
• In longer procedures, use comments to break up units of work within the
procedure.
• When you declare variables, use a comment to indicate how the variable will
be used.
• When you write a decision structure, use a comment to indicate how the
decision is made and what it implies.

Question: Why is it important for you to comment your code?


1-44 Programming in C# with Microsoft® .Visual Studio® 2010

Lesson 4
Building a Graphical Application

This lesson introduces you to applications that have a graphical user interface, and
provides the example of a WPF application.
This lesson also explains what WPF is, how WPF applications are structured, and
how you can create your own WPF applications by using Visual Studio 2010.

Objectives
After completing this lesson, you will be able to:
• Describe the purpose of WPF.
• Describe the structure of a WPF application.
• Describe the controls that WPF provides, and how to set control properties.
• Describe the concept of events, and how WPF controls use events.
• Explain how to build a simple WPF application by using Visual Studio 2010.
Other documents randomly have
different content
T. CRESWICK, R.A.
C. DAVIDSON.
W. LEE.
J. MULLER.
E. DUNCAN.
BIRKET FOSTER.
D. COX.
H. LE JEUNE.
W. HEMSLEY.
C. BRANWHITE.
J. WOLF.
C. WEIGALL.
HARRISON WEIR.
R. R.
E. V. B.
LUCETTE E. BARKER.

"Christmas has seldom produced a gift-book more creditable to


all concerned in it than this beautiful volume. The poetry is well
chosen; the passages being for the most part bits of real
description, excellent in their kind, from the writings of our
poets, from the time of Lord Surrey to that of Tennyson, with
two or three beautiful bits from American authors. Now and
then a poem is inserted, which, if not descriptive, is in spirit and
feeling akin to the season to which it is referred; and this gives
variety to what might otherwise be too great a mass of
description. As a book of extracts merely, it would be an
intelligent and creditable selection, made upon a distinct and
coherent plan. But the drawings of Messrs. Foster, Davidson,
Weir, Creswick, Cox, Duncan, and Branwhite, are a great
addition to the volume; and the coloured engravings have been
happy in catching the spirit and character of the artist
themselves.
"Though on a small scale, the feeling of some of the designs is
admirable, specially those devoted to the illustration of spring
and summer—the seasons which, both in poetry and painting,
have the greatest amount of honour in this volume. The
publisher is entitled to the praise of great care and attention to
the appearance of the book; the colour and texture of the
paper, the type, and the binding are unexceptionable. It is a
book to do credit to any publisher."—Guardian.

GEORGE BELL, 186. Fleet Street.

Printed by Thomas Clark Shaw, of No. 8. New Street Square, at No. 5


New Street Square, in the Parish of St. Bride, in the City of London;
and published by George Bell, of No. 186. Fleet Street, in the Parish
of St. Dunstan in the West, in the City of London, Publisher, at No.
186. Fleet Street aforesaid.—Saturday, January 15. 1853.
*** END OF THE PROJECT GUTENBERG EBOOK NOTES AND
QUERIES, NUMBER 168, JANUARY 15, 1853 ***

Updated editions will replace the previous one—the old editions


will be renamed.

Creating the works from print editions not protected by U.S.


copyright law means that no one owns a United States
copyright in these works, so the Foundation (and you!) can copy
and distribute it in the United States without permission and
without paying copyright royalties. Special rules, set forth in the
General Terms of Use part of this license, apply to copying and
distributing Project Gutenberg™ electronic works to protect the
PROJECT GUTENBERG™ concept and trademark. Project
Gutenberg is a registered trademark, and may not be used if
you charge for an eBook, except by following the terms of the
trademark license, including paying royalties for use of the
Project Gutenberg trademark. If you do not charge anything for
copies of this eBook, complying with the trademark license is
very easy. You may use this eBook for nearly any purpose such
as creation of derivative works, reports, performances and
research. Project Gutenberg eBooks may be modified and
printed and given away—you may do practically ANYTHING in
the United States with eBooks not protected by U.S. copyright
law. Redistribution is subject to the trademark license, especially
commercial redistribution.

START: FULL LICENSE


THE FULL PROJECT GUTENBERG LICENSE
PLEASE READ THIS BEFORE YOU DISTRIBUTE OR USE THIS WORK

To protect the Project Gutenberg™ mission of promoting the


free distribution of electronic works, by using or distributing this
work (or any other work associated in any way with the phrase
“Project Gutenberg”), you agree to comply with all the terms of
the Full Project Gutenberg™ License available with this file or
online at www.gutenberg.org/license.

Section 1. General Terms of Use and


Redistributing Project Gutenberg™
electronic works
1.A. By reading or using any part of this Project Gutenberg™
electronic work, you indicate that you have read, understand,
agree to and accept all the terms of this license and intellectual
property (trademark/copyright) agreement. If you do not agree
to abide by all the terms of this agreement, you must cease
using and return or destroy all copies of Project Gutenberg™
electronic works in your possession. If you paid a fee for
obtaining a copy of or access to a Project Gutenberg™
electronic work and you do not agree to be bound by the terms
of this agreement, you may obtain a refund from the person or
entity to whom you paid the fee as set forth in paragraph 1.E.8.

1.B. “Project Gutenberg” is a registered trademark. It may only


be used on or associated in any way with an electronic work by
people who agree to be bound by the terms of this agreement.
There are a few things that you can do with most Project
Gutenberg™ electronic works even without complying with the
full terms of this agreement. See paragraph 1.C below. There
are a lot of things you can do with Project Gutenberg™
electronic works if you follow the terms of this agreement and
help preserve free future access to Project Gutenberg™
electronic works. See paragraph 1.E below.
1.C. The Project Gutenberg Literary Archive Foundation (“the
Foundation” or PGLAF), owns a compilation copyright in the
collection of Project Gutenberg™ electronic works. Nearly all the
individual works in the collection are in the public domain in the
United States. If an individual work is unprotected by copyright
law in the United States and you are located in the United
States, we do not claim a right to prevent you from copying,
distributing, performing, displaying or creating derivative works
based on the work as long as all references to Project
Gutenberg are removed. Of course, we hope that you will
support the Project Gutenberg™ mission of promoting free
access to electronic works by freely sharing Project Gutenberg™
works in compliance with the terms of this agreement for
keeping the Project Gutenberg™ name associated with the
work. You can easily comply with the terms of this agreement
by keeping this work in the same format with its attached full
Project Gutenberg™ License when you share it without charge
with others.

1.D. The copyright laws of the place where you are located also
govern what you can do with this work. Copyright laws in most
countries are in a constant state of change. If you are outside
the United States, check the laws of your country in addition to
the terms of this agreement before downloading, copying,
displaying, performing, distributing or creating derivative works
based on this work or any other Project Gutenberg™ work. The
Foundation makes no representations concerning the copyright
status of any work in any country other than the United States.

1.E. Unless you have removed all references to Project


Gutenberg:

1.E.1. The following sentence, with active links to, or other


immediate access to, the full Project Gutenberg™ License must
appear prominently whenever any copy of a Project
Gutenberg™ work (any work on which the phrase “Project
Gutenberg” appears, or with which the phrase “Project
Gutenberg” is associated) is accessed, displayed, performed,
viewed, copied or distributed:

This eBook is for the use of anyone anywhere in the United


States and most other parts of the world at no cost and
with almost no restrictions whatsoever. You may copy it,
give it away or re-use it under the terms of the Project
Gutenberg License included with this eBook or online at
www.gutenberg.org. If you are not located in the United
States, you will have to check the laws of the country
where you are located before using this eBook.

1.E.2. If an individual Project Gutenberg™ electronic work is


derived from texts not protected by U.S. copyright law (does not
contain a notice indicating that it is posted with permission of
the copyright holder), the work can be copied and distributed to
anyone in the United States without paying any fees or charges.
If you are redistributing or providing access to a work with the
phrase “Project Gutenberg” associated with or appearing on the
work, you must comply either with the requirements of
paragraphs 1.E.1 through 1.E.7 or obtain permission for the use
of the work and the Project Gutenberg™ trademark as set forth
in paragraphs 1.E.8 or 1.E.9.

1.E.3. If an individual Project Gutenberg™ electronic work is


posted with the permission of the copyright holder, your use and
distribution must comply with both paragraphs 1.E.1 through
1.E.7 and any additional terms imposed by the copyright holder.
Additional terms will be linked to the Project Gutenberg™
License for all works posted with the permission of the copyright
holder found at the beginning of this work.

1.E.4. Do not unlink or detach or remove the full Project


Gutenberg™ License terms from this work, or any files
containing a part of this work or any other work associated with
Project Gutenberg™.

1.E.5. Do not copy, display, perform, distribute or redistribute


this electronic work, or any part of this electronic work, without
prominently displaying the sentence set forth in paragraph 1.E.1
with active links or immediate access to the full terms of the
Project Gutenberg™ License.

1.E.6. You may convert to and distribute this work in any binary,
compressed, marked up, nonproprietary or proprietary form,
including any word processing or hypertext form. However, if
you provide access to or distribute copies of a Project
Gutenberg™ work in a format other than “Plain Vanilla ASCII” or
other format used in the official version posted on the official
Project Gutenberg™ website (www.gutenberg.org), you must,
at no additional cost, fee or expense to the user, provide a copy,
a means of exporting a copy, or a means of obtaining a copy
upon request, of the work in its original “Plain Vanilla ASCII” or
other form. Any alternate format must include the full Project
Gutenberg™ License as specified in paragraph 1.E.1.

1.E.7. Do not charge a fee for access to, viewing, displaying,


performing, copying or distributing any Project Gutenberg™
works unless you comply with paragraph 1.E.8 or 1.E.9.

1.E.8. You may charge a reasonable fee for copies of or


providing access to or distributing Project Gutenberg™
electronic works provided that:

• You pay a royalty fee of 20% of the gross profits you derive
from the use of Project Gutenberg™ works calculated using the
method you already use to calculate your applicable taxes. The
fee is owed to the owner of the Project Gutenberg™ trademark,
but he has agreed to donate royalties under this paragraph to
the Project Gutenberg Literary Archive Foundation. Royalty
payments must be paid within 60 days following each date on
which you prepare (or are legally required to prepare) your
periodic tax returns. Royalty payments should be clearly marked
as such and sent to the Project Gutenberg Literary Archive
Foundation at the address specified in Section 4, “Information
about donations to the Project Gutenberg Literary Archive
Foundation.”

• You provide a full refund of any money paid by a user who


notifies you in writing (or by e-mail) within 30 days of receipt
that s/he does not agree to the terms of the full Project
Gutenberg™ License. You must require such a user to return or
destroy all copies of the works possessed in a physical medium
and discontinue all use of and all access to other copies of
Project Gutenberg™ works.

• You provide, in accordance with paragraph 1.F.3, a full refund of


any money paid for a work or a replacement copy, if a defect in
the electronic work is discovered and reported to you within 90
days of receipt of the work.

• You comply with all other terms of this agreement for free
distribution of Project Gutenberg™ works.

1.E.9. If you wish to charge a fee or distribute a Project


Gutenberg™ electronic work or group of works on different
terms than are set forth in this agreement, you must obtain
permission in writing from the Project Gutenberg Literary
Archive Foundation, the manager of the Project Gutenberg™
trademark. Contact the Foundation as set forth in Section 3
below.

1.F.

1.F.1. Project Gutenberg volunteers and employees expend


considerable effort to identify, do copyright research on,
transcribe and proofread works not protected by U.S. copyright
law in creating the Project Gutenberg™ collection. Despite these
efforts, Project Gutenberg™ electronic works, and the medium
on which they may be stored, may contain “Defects,” such as,
but not limited to, incomplete, inaccurate or corrupt data,
transcription errors, a copyright or other intellectual property
infringement, a defective or damaged disk or other medium, a
computer virus, or computer codes that damage or cannot be
read by your equipment.

1.F.2. LIMITED WARRANTY, DISCLAIMER OF DAMAGES - Except


for the “Right of Replacement or Refund” described in
paragraph 1.F.3, the Project Gutenberg Literary Archive
Foundation, the owner of the Project Gutenberg™ trademark,
and any other party distributing a Project Gutenberg™ electronic
work under this agreement, disclaim all liability to you for
damages, costs and expenses, including legal fees. YOU AGREE
THAT YOU HAVE NO REMEDIES FOR NEGLIGENCE, STRICT
LIABILITY, BREACH OF WARRANTY OR BREACH OF CONTRACT
EXCEPT THOSE PROVIDED IN PARAGRAPH 1.F.3. YOU AGREE
THAT THE FOUNDATION, THE TRADEMARK OWNER, AND ANY
DISTRIBUTOR UNDER THIS AGREEMENT WILL NOT BE LIABLE
TO YOU FOR ACTUAL, DIRECT, INDIRECT, CONSEQUENTIAL,
PUNITIVE OR INCIDENTAL DAMAGES EVEN IF YOU GIVE
NOTICE OF THE POSSIBILITY OF SUCH DAMAGE.

1.F.3. LIMITED RIGHT OF REPLACEMENT OR REFUND - If you


discover a defect in this electronic work within 90 days of
receiving it, you can receive a refund of the money (if any) you
paid for it by sending a written explanation to the person you
received the work from. If you received the work on a physical
medium, you must return the medium with your written
explanation. The person or entity that provided you with the
defective work may elect to provide a replacement copy in lieu
of a refund. If you received the work electronically, the person
or entity providing it to you may choose to give you a second
opportunity to receive the work electronically in lieu of a refund.
If the second copy is also defective, you may demand a refund
in writing without further opportunities to fix the problem.

1.F.4. Except for the limited right of replacement or refund set


forth in paragraph 1.F.3, this work is provided to you ‘AS-IS’,
WITH NO OTHER WARRANTIES OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO WARRANTIES OF
MERCHANTABILITY OR FITNESS FOR ANY PURPOSE.

1.F.5. Some states do not allow disclaimers of certain implied


warranties or the exclusion or limitation of certain types of
damages. If any disclaimer or limitation set forth in this
agreement violates the law of the state applicable to this
agreement, the agreement shall be interpreted to make the
maximum disclaimer or limitation permitted by the applicable
state law. The invalidity or unenforceability of any provision of
this agreement shall not void the remaining provisions.

1.F.6. INDEMNITY - You agree to indemnify and hold the


Foundation, the trademark owner, any agent or employee of the
Foundation, anyone providing copies of Project Gutenberg™
electronic works in accordance with this agreement, and any
volunteers associated with the production, promotion and
distribution of Project Gutenberg™ electronic works, harmless
from all liability, costs and expenses, including legal fees, that
arise directly or indirectly from any of the following which you
do or cause to occur: (a) distribution of this or any Project
Gutenberg™ work, (b) alteration, modification, or additions or
deletions to any Project Gutenberg™ work, and (c) any Defect
you cause.

Section 2. Information about the Mission


of Project Gutenberg™
Project Gutenberg™ is synonymous with the free distribution of
electronic works in formats readable by the widest variety of
computers including obsolete, old, middle-aged and new
computers. It exists because of the efforts of hundreds of
volunteers and donations from people in all walks of life.

Volunteers and financial support to provide volunteers with the


assistance they need are critical to reaching Project
Gutenberg™’s goals and ensuring that the Project Gutenberg™
collection will remain freely available for generations to come. In
2001, the Project Gutenberg Literary Archive Foundation was
created to provide a secure and permanent future for Project
Gutenberg™ and future generations. To learn more about the
Project Gutenberg Literary Archive Foundation and how your
efforts and donations can help, see Sections 3 and 4 and the
Foundation information page at www.gutenberg.org.

Section 3. Information about the Project


Gutenberg Literary Archive Foundation
The Project Gutenberg Literary Archive Foundation is a non-
profit 501(c)(3) educational corporation organized under the
laws of the state of Mississippi and granted tax exempt status
by the Internal Revenue Service. The Foundation’s EIN or
federal tax identification number is 64-6221541. Contributions
to the Project Gutenberg Literary Archive Foundation are tax
deductible to the full extent permitted by U.S. federal laws and
your state’s laws.

The Foundation’s business office is located at 809 North 1500


West, Salt Lake City, UT 84116, (801) 596-1887. Email contact
links and up to date contact information can be found at the
Foundation’s website and official page at
www.gutenberg.org/contact
Section 4. Information about Donations to
the Project Gutenberg Literary Archive
Foundation
Project Gutenberg™ depends upon and cannot survive without
widespread public support and donations to carry out its mission
of increasing the number of public domain and licensed works
that can be freely distributed in machine-readable form
accessible by the widest array of equipment including outdated
equipment. Many small donations ($1 to $5,000) are particularly
important to maintaining tax exempt status with the IRS.

The Foundation is committed to complying with the laws


regulating charities and charitable donations in all 50 states of
the United States. Compliance requirements are not uniform
and it takes a considerable effort, much paperwork and many
fees to meet and keep up with these requirements. We do not
solicit donations in locations where we have not received written
confirmation of compliance. To SEND DONATIONS or determine
the status of compliance for any particular state visit
www.gutenberg.org/donate.

While we cannot and do not solicit contributions from states


where we have not met the solicitation requirements, we know
of no prohibition against accepting unsolicited donations from
donors in such states who approach us with offers to donate.

International donations are gratefully accepted, but we cannot


make any statements concerning tax treatment of donations
received from outside the United States. U.S. laws alone swamp
our small staff.

Please check the Project Gutenberg web pages for current


donation methods and addresses. Donations are accepted in a
number of other ways including checks, online payments and
credit card donations. To donate, please visit:
www.gutenberg.org/donate.

Section 5. General Information About


Project Gutenberg™ electronic works
Professor Michael S. Hart was the originator of the Project
Gutenberg™ concept of a library of electronic works that could
be freely shared with anyone. For forty years, he produced and
distributed Project Gutenberg™ eBooks with only a loose
network of volunteer support.

Project Gutenberg™ eBooks are often created from several


printed editions, all of which are confirmed as not protected by
copyright in the U.S. unless a copyright notice is included. Thus,
we do not necessarily keep eBooks in compliance with any
particular paper edition.

Most people start at our website which has the main PG search
facility: www.gutenberg.org.

This website includes information about Project Gutenberg™,


including how to make donations to the Project Gutenberg
Literary Archive Foundation, how to help produce our new
eBooks, and how to subscribe to our email newsletter to hear
about new eBooks.
Welcome to our website – the perfect destination for book lovers and
knowledge seekers. We believe that every book holds a new world,
offering opportunities for learning, discovery, and personal growth.
That’s why we are dedicated to bringing you a diverse collection of
books, ranging from classic literature and specialized publications to
self-development guides and children's books.

More than just a book-buying platform, we strive to be a bridge


connecting you with timeless cultural and intellectual values. With an
elegant, user-friendly interface and a smart search system, you can
quickly find the books that best suit your interests. Additionally,
our special promotions and home delivery services help you save time
and fully enjoy the joy of reading.

Join us on a journey of knowledge exploration, passion nurturing, and


personal growth every day!

ebookbell.com

You might also like