1.33. C # enumeration

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

Page Views: 32 views

An enumeration is a set of named integer constants. Enumerated types are made using the enum keyword.

The C # enumeration is a value type. In other words, enumerations contain their own values and cannot inherit or pass inheritance.

1.33.1. Statement enum variable #

General syntax for declaring enumerations:

enum <enum_name>
{
    enumeration list
};

Among them

  • enum_name specifies the type name of the enumeration.

  • enumeration list is a comma-separated list of identifiers.

Each symbol in the enumerated list represents an integer value, an integer value larger than the symbol that precedes it. By default, the value of the first enumeration symbol is 0. 0. For example:

enum Days { Sun, Mon, tue, Wed, thu, Fri, Sat };

1.33.2. Example #

The following example demonstrates the use of enumerated variables:

Example #

using System;
public class EnumTest
{
    enum Day { Sun, Mon, Tue, Wed, Thu, Fri, Sat };
    static void Main()
    {
        int x = (int)Day.Sun;
        int y = (int)Day.Fri;
        Console.WriteLine("Sun = {0}", x);
        Console.WriteLine("Fri = {0}", y);
    }
}

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

Sun = 0
Fri = 5
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.