1.13. C# nesting if statement

发布时间 : 2025-10-25 13:34:39 UTC      

Page Views: 9 views

In C #, nesting if-else statement is legal, which means that you can use a if or else if use another within the statement if or else if statement.

1.13.1. Grammar #

Nesting in C # if syntax of the statement:

if( boolean_expression 1) { /* Execute when Boolean expression 1 is true */ if(boolean_expression 2) { /* Execute when Boolean expression 2 is true */ } } 

You can nest else if...else , mode and nesting if sentence is similar.

1.13.2. Example #

using System; namespace DecisionMaking { class Program { static void Main(string[] args) { //* Definition of Local Variables */ int a = 100; int b = 200; /* Check Boolean conditions */ if (a == 100) { /* If the condition is true, check the following conditions */ if (b == 200) { /* If the condition is true, output the following statement */ Console.WriteLine("The value of a is 100, and the value of b is 200"); } } Console.WriteLine("The exact value of a is {0}", a); Console.WriteLine("The exact value of b is {0}", b); Console.ReadLine(); } } } 

When the above code is compiled and executed, it produces the following results:

The value of a is 100, and the value of b is 200 The accurate value of a is 100 The accurate value of b is 200 
《地理信息系统原理、技术与方法》  97

最近几年来,地理信息系统无论是在理论上还是应用上都处在一个飞速发展的阶段。 GIS被应用于多个领域的建模和决策支持,如城市管理、区划、环境整治等等,地理信息成为信息时代重要的组成部分之一; “数字地球”概念的提出,更进一步推动了作为其技术支撑的GIS的发展。 与此同时,一些学者致力于相关的理论研究,如空间感知、空间数据误差、空间关系的形式化等等。 这恰好说明了地理信息系统作为应用技术和学科的两个方面,并且这两个方面构成了相互促进的发展过程。