1.13. C# nesting if statement

发布时间 : 2023-10-12 23:00:08 UTC      

Page Views: Stats unavailable

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
Principles, Technologies, and Methods of Geographic Information Systems  102

In recent years, Geographic Information Systems (GIS) have undergone rapid development in both theoretical and practical dimensions. GIS has been widely applied for modeling and decision-making support across various fields such as urban management, regional planning, and environmental remediation, establishing geographic information as a vital component of the information era. The introduction of the “Digital Earth” concept has further accelerated the advancement of GIS, which serves as its technical foundation. Concurrently, scholars have been dedicated to theoretical research in areas like spatial cognition, spatial data uncertainty, and the formalization of spatial relationships. This reflects the dual nature of GIS as both an applied technology and an academic discipline, with the two aspects forming a mutually reinforcing cycle of progress.