Đang chuẩn bị liên kết để tải về tài liệu:
Lesson 3: Control Statements - Selection

Đang chuẩn bị nút TẢI XUỐNG, xin hãy chờ

This lesson teaches you how to use C# Selection Control Statements. | Tutorial Page 1 of 7 Using Excellent Tools to Write Web Applications Tar the .NET Common Language Runtime CLR Home Up Lesson01 Lesson02 Lesson03 Lesson04 Les Lesson06 Lesson07 Lesson08 Lesson09 Lesson10 Les Lesson12 Lesson13 The C Station Tutorial by Joe Mayo 9 2 00 updated 10 6 01 Lesson 3 Control Statements - Selection On sale Now C Unleashed is an indepth guide for intermediate to advanced software developers to learn the C programming language and serve as a desktop reference. This lesson teaches you how to use C Selection Control Statements. Its goal is to meet the following objectives Learn the if statements. Learn the switch statement. Learn how break is used in switch statements. Understand proper use of the goto statement. In the last couple of lessons every program you saw contained a limited amount of sequential steps and then stopped. There were no decisions you could make with the input and the only constraint was to follow straight through to the end. The information in this lesson will help you branch into separate logical sequences based on decisions you make. Our first selection statement is the if statement. It has three primary forms a single decision an either or decision and multi-case decision. Listing 3-1. Forms of the IF statement IfSelection.cs using System class IfSelect public static void Main string myInput int myInt Console.Write Please enter a number myInput Console.ReadLine myInt Int32.Parse myInput Single Decision and Action with brackets http www.csharp-station.com Tutorials Lesson03.aspx 6 24 2002 Tutorial Page 2 of 7 if myInt 0 Console.WriteLine Your number 0 is greater than zero. myInt Single Decision and Action without brackets if myInt 0 Console.WriteLine Your number 0 is less than zero. myInt Either Or Decision if myInt 0 Console.WriteLine Your number 0 is not equal to zero. myInt else Console.WriteLine Your number 0 is equal to zero. myInt Multiple Case Decision if myInt 0 myInt 0 Console.WriteLine Your number 0 is less than