Documenti di Didattica
Documenti di Professioni
Documenti di Cultura
OFFICIAL
MICROSOFT
LEARNING
PRODUCT
10266A
Programming in C# with Microsoft Visual Studio 2010
ii
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.
Module 1
Lab Instructions: Introducing C# and the .NET Framework
Contents:
Exercise 1: Building a Simple Console Application Exercise 2: Building a WPF Application Exercise 3: Verifying the Application Exercise 4: Generating Documentation for an Application 5 10 14 17
Objectives
After completing this lab, you will be able to: Create, build, and run a simple console application by using Visual Studio 2010 and C# 4.0. Create, build, and run a basic WPF application by using Visual Studio 2010. Use the Visual Studio 2010 debugger to set breakpoints, step through code, and examine the values of variables. Generate documentation for an application.
Introduction
In this lab, you will create simple console and WPF solutions to get started with using Visual Studio 2010 and C#. You will also configure projects, use code-editing features, and create comments. You will become familiar with the debugger
interface. You will compile, run, and use the debugger to step through a program. Finally, you will generate documentation for an application.
Lab Setup
For this lab, you will use the available virtual machine environment. Before you begin the lab, you must: Start the 10266A-GEN-DEV virtual machine, and then log on by using the following credentials: User name: Student Password: Pa$$w0rd
Note: Step-by-step instructions for completing the labs in this course are available in the lab answer keys provided. Completed, working code is available in the Solution folders under the Labfiles folder for each lab exercise on the virtual machine.
Lab Scenario
Fabrikam, Inc. produces a range of highly sensitive measuring devices that can repeatedly measure objects and capture data. You have been asked to write a C# application to read a small set of input data that a measuring device has generated, format this data to make it more readable, and then display the formatted results. The data consists of text data that contains pairs of numbers representing xcoordinates and y-coordinates of the location of an object. Each line of text contains one set of coordinates. The following code example resembles a typical dataset.
23.8976,12.3218 25.7639,11.9463 24.8293,12.2134
You have been asked to format the data like the following code example.
x:23.8976 y:12.3218 x:25.7639 y:11.9463 x:24.8293 y:12.2134
Scenario
As a prototype, you have decided to implement a console application to read input from the keyboard and format it. When you are happy that your code is working, you will then run the code and redirect input to come from a file that contains the data that you want to format. The main tasks for this exercise are as follows: 1. 2. 3. 4. 5. Create a new Console Application project. Add code to read user input and write output to the console. Modify the program to read and echo text until end-of-file is detected. Add code to format the data and display it. Test the application by using a data file.