Abstract
An array is a container that holds data while it is being manipulated by a computer program. More specifically, it is a data structure that consists of a collection of elements of the same type, where each element contains its own value and is identified by one or more indices (a.k.a., subscripts). Arrays can be one-dimensional or multidimensional. The elements of a one-dimensional array are referenced by a single index, the elements of a two-dimensional array are referenced by two indices, and so on. It is not uncommon to see arrays of three or more dimensions. The total number of elements in an array is its length. Each dimension of an array has a lower bound (i.e., the index of the first element of the array) and an upper bound (i.e., the index of the last element of the array). Since arrays are zero based in C# by default, the index of the first element in a one-dimensional array is [0], the index of the second element is [1], and so on. The index of the first element in a two-dimensional array is [0, 0], the index of the second element is [0, 1], and so on. An array is statically allocated. That is, its capacity cannot be altered once it is declared. An array is considered an internal data structure because it resides in RAM and only remains there until the program that utilizes it terminates. Thus, the data in an array is said to be nonpersistent. This is in contrast to a database table, which is considered an external data structure because it resides on a peripheral device (e.g., a magnetic disk) and remains there even after the program that utilizes it terminates. Thus, the data in a database table is said to be persistent.
Access this chapter
Tax calculation will be finalised at checkout
Purchases are for personal use only
Notes
- 1.
Arrays can even contain other arrays. These arrays are called jagged arrays. We will not consider jagged arrays in this book.
- 2.
In C#, multidimensional arrays of up to 32 dimensions can be declared.
- 3.
The Array class permits us to define different lower bounds if desired.
- 4.
All property, method, and event descriptions were taken directly from Microsoft’s official documentation. The event handler methods used to handle the events of this class were omitted to conserve space. See the reference for all of the methods of this class.
- 5.
Although sorting was mentioned in this list of array operations, the Array class does not contain a static Sort method for sorting two-dimensional arrays. If sorting such an array were required, we would have to write the code necessary to sort it.
Author information
Authors and Affiliations
Rights and permissions
Copyright information
© 2020 Robert E. Beasley
About this chapter
Cite this chapter
Beasley, R.E. (2020). Array Operations . In: Essential ASP.NET Web Forms Development. Apress, Berkeley, CA. https://doi.org/10.1007/978-1-4842-5784-5_12
Download citation
DOI: https://doi.org/10.1007/978-1-4842-5784-5_12
Published:
Publisher Name: Apress, Berkeley, CA
Print ISBN: 978-1-4842-5783-8
Online ISBN: 978-1-4842-5784-5
eBook Packages: Professional and Applied ComputingApress Access BooksProfessional and Applied Computing (R0)