1.30. C # Array class

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

Page Views: 9 views

Array class is the base class for all arrays in C #. It is defined in the System , which is defined in the namespace. Array class provides a variety of properties and methods for arrays.

1.30.1. Properties of the Array class #

The following table lists some of the most commonly used properties in the Array :

Serial number

Attribute & description

1

IsFixedSize gets a value indicating whether the array has a fixed size.

2

IsReadOnly gets a value indicating whether the array is read-only.

3

Length gets a 32-bit integer that represents the total number of elements inthe array of all dimensions.

4

LongLength gets a 64-bit integer that represents the total number of elements in the array of all dimensions.

5

Rank gets the rank (dimension) of the array.

If you need to know Array for a complete list of properties of the class, please refer to Microsoft’s C # documentation.

1.30.2. Methods of the Array class #

The following table lists some of the most commonly used methods in the Array :

Serial number

Method & description

1

Clear sets a range of elements in the array to zero, false, or null, depending on the type of element.

2

Copy (Array, Array, Int32) copies a range of elements from the first elementof the array to the first element position of another array. The length is specified by a 32-bit integer.

3

CopyTo (Array, Int32) copies all elements from the current one-dimensional array to the specified index location of a specified one-dimensional array. The index is specified by a 32-bit integer.

4

GetLength gets a 32-bit integer that represents the total number of elementsin the array of the specified dimension.

5

GetLongLength gets a 64-bit integer that represents the total number of elements in the array of the specified dimension.

6

GetLowerBound gets the lower bound of the specified dimension in the array.

7

GetType gets the type of the current instance. Inherits from objects.

8

GetUpperBound gets the upper bound of the specified dimension in the array.

9

GetValue (Int32) gets the value of the specified position in an one - dimensional array. The index is specified by a 32-bit integer.

10

IndexOf (Array, Object) searches for the specified object and returns the index that first appears in the entire one-dimensional array.

11

Reverse (Array) reverses the order of elements in the entire one-dimensionalarray.

12

SetValue (Object, Int32) sets a value for the element at the specified position in the one-dimensional array. The index is specified by a 32-bit integer.

13

Sort (Array) uses the IComparable implementation of each element of the array to sort the elements in the entire one-dimensional array.

14

ToString returns a string that represents the current object. Inherits from objects.

If you need to know Array for a complete list of methods for the class,please refer to Microsoft’s C # documentation.

1.30.3. Example #

The following program demonstrates the use of some methods of Array :

Example #

using System; namespace ArrayApplication { class MyArray { static void Main(string[] args) { int[] list = { 34, 72, 13, 44, 25, 30, 10 }; Console.Write("Original array: "); foreach (int i in list) { Console.Write(i + " "); } Console.WriteLine(); // Reverse Array Array.Reverse(list); Console.Write("Reverse Array: "); foreach (int i in list) { Console.Write(i + " "); } Console.WriteLine(); // Sort Array Array.Sort(list); Console.Write("Sort Array: "); foreach (int i in list) { Console.Write(i + " "); } Console.WriteLine(); Console.ReadKey(); } } } 

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

Original array: 34 72 13 44 25 30 10 Reverse array: 10 30 25 44 13 72 34 Sort array: 10 13 25 30 34 44 72 
《地理信息系统原理、技术与方法》  97

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