Using One-Dimensional Arrays in C# Programming

In C#, a one-dimensional array's elements are indexed starting from 0. For example, to access elements of an array called integers with 32 elements:

- integers[0] = 23; assigns a value to the first element.

- integers[31] = 67; assigns a value to the 32nd element.

- integers[i] = 90; assigns a value to the i+1th element.

The Array class in C# offers methods for creating, manipulating, searching, and sorting arrays. It is the base class for all arrays in the Common Language Runtime (CLR). One of the most commonly used properties is the Length property, which provides the array's size. Example:

int[] Integers = {2, 6, -1, 10, 12};
int ArrayLength = Integers.Length;

This code calculates the length of the Integers array.

ppt 文件大小:447.5KB