This module explains how to use some common statements in C#. It also explains how to implement exception handling in C#. In particular, it shows how to throw errors as well as catch them, and how to use try-finally blocks to ensure that an exception does not cause the program to stop before cleaning up. After completing this module, students will be able to: Describe the different types of control statements. Use jump statements. Use selection statements. Use iteration statements. Handle and raise exceptions in a C# application | msdn training Module 4 Statements and Exceptions Contents Overview 1 Introduction to Statements 2 Using Selection Statements 6 Using Iteration Statements 17 Using Jump Statements 29 Lab Using Statements 32 Handling Basic Exceptions 42 Raising Exceptions 52 Lab Using Exceptions 62 Review 72 Microsoft 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 places or events 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. 2001-2002 Microsoft Corporation. All rights reserved. Microsoft MS-DOS Windows Windows NT ActiveX BizTalk IntelliSense JScript MSDN PowerPoint SQL Server Visual Basic Visual C Visual C Visual J Visual Studio and Win32 are either registered trademarks or trademarks of Microsoft Corporation in the . and or other countries. The names of actual companies and products mentioned herein may be the trademarks of their respective owners. Module 4 Statements and Exceptions iii Instructor Notes .