Array in Csharp C# – A Complete Tutorial
Array – A data structure that contains a number of variables called elements of the array
- All of the array elements must be of the same type
- Arrays are zero indexed
- Arrays are objects
Arrays can be:
Single Dimensional Array – an array with the rank of one.
Multidimensional Array – an array with a rank greater than one
Jagged Array – an array whose elements are array.
System.Array – is an abstract class that provides many methods that you can use when working with arrays.
Example:
int[] numbers = {1, 2, 3, 4, 5}; int LengthOfNumbers = numbers.Length;
Clear – Sets a range of elements in the Array to zero, to false, or to null, depending on the element type.
Clone – Creates a shallow copy of the Array.
Find<T> – Searches for an element that matches the conditions defined by the specified predicate, and returns the first occurrence within the entire Array.
GetLength – Gets a 32-bit integer that represents the number of elements in the specified dimension of the Array.
Reverse – Reverses the sequence of the elements in the entire one-dimensional Array.
Sort – Sorts the elements in an entire one-dimensional Array using the IComparable implementation of each element of the Array.
IndexOf – returns the index of the first occurrence of a value.
Length – Gets the number of elements in the specified dimension of the array.
GetLength – returns the elements of the given dimension.
Sample code:
Hi, super interesting. Thanks!