Ms 10266a Programming In C With Visual Studio 2010 Vol 1 Student Manual download
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
https://ebookbell.com/product/ms-course-10266a-programming-in-c-with-
microsoft-visual-studio-2010-trainer-edition-
volume-1-microsoft-2113632
https://ebookbell.com/product/ms-course-10266a-programming-in-c-with-
microsoft-visual-studio-2010-trainer-edition-
volume-2-microsoft-2113634
https://ebookbell.com/product/ms-fortune-drive-me-wild-1-amy-
booker-45697342
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
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
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
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.
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 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
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
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:
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.
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
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.
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
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
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
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
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
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:
• 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
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.
Template Description
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
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.
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.
• 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
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
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.
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
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
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.
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.
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
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
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
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
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
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.
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
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!");
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
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.
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.
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.
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.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.
• 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 comply with all other terms of this agreement for free
distribution of Project Gutenberg™ works.
1.F.
Most people start at our website which has the main PG search
facility: www.gutenberg.org.
ebookbell.com