Arrays and indexers | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 2

Arrays and indexers

What's the difference between arrays and objects with indexers?

11th Nov 2016, 8:31 AM
Cthulhu Tamer
Cthulhu Tamer - avatar
2 Answers
+ 8
In an array you can go directly to the value you want. As you know you can write arr[2] (for example) and get the value under index 2. Indexer is a property that allows you to go directly to the value you want(like in arrays), in cases when you do not use array.
11th Nov 2016, 9:09 AM
Remmae
Remmae - avatar
+ 1
Array:- An array is a collection of variables of the same type that are referred to by a common name. Indexers:- An indexer allows an object to be indexed like an array. The main use of indexers is to support the creation of specialized arrays that are subject to one or more constraints. however, you can use an indexer for any purpose for which an array-like syntax is beneficial, Indexers can have one or more dimensions.
10th Dec 2016, 6:37 PM
Paras Jain
Paras Jain - avatar