Category Archive for: Arrays

Enumerations

By using the foreach statement you can iterate elements of a collection without the need to know the number of elements inside the collection. The foreach statement uses an enumerator. Figure 5-7shows the relationship between the client invoking the foreach method and the collection. The array or collection implements the IEnUlll9rable interface with the GetEnumerator () method. The…

Read More →

Array and Collection Interfaces

The Array class implements the interfaces IEnumerable, ICollection, and IList for accessing and enumerating the elements of the array. Because with a custom array a class is created that derives from the abstract class Array, you can use the methods and properties of the implemented interfaces with an array variable. IEnumerable IEnumerable is an interface that is used…

Read More →

Array Class

Declaring an array with brackets is a C# notation of using the Array class. Using the C# syntax behind the scenes creates a new class that derives from the abstract base class Array. It is possible, in this way, to use methods and properties that are defined with the Array class with every C# array. For example, you’ve…

Read More →

Jagged Arrays

A 2-dimensional array has a rectangular size (for example, 3 x 3 elements). A jagged array is more flexible in sizing the array. With a jagged array every row can have a different size. It contrasts a 2-dimensional array that has 3 x 3 elements with a jagged array. The jagged array shown contains three rows where…

Read More →

Multidimensional Arrays

Ordinary arrays (also known as 1-dimensional arrays) are indexed by a single integer. A multidimensional array is indexed by two or more integers. the mathematical notation for a 2-dimensional array that has three rows and three columns. The first row has the values 1, 2, and 3, and the third row has the values 7, 8, and…

Read More →

Simple Arrays

If you need to use multiple objects of the same type, you can use an array. An array is a data structure that contains a number of elements of the same type. Array Declaration An array is declared by defining the type of the elements inside the array followed by empty brackets and a variable name; for…

Read More →

Arrays

If you need to work with multiple objects of the same type, you can use collections and arrays. elf has a special notation to declare and use arrays. Behind the scenes, the Array class comes into play, which offers several methods to sort and filter the elements inside the array. Using an enumerator, you can…

Read More →

Back to Top