1.

Which among the following are the advantages of using indexers?(a) To use collection of items at a large scale we make use of indexers as they utilize objects of class that represent the collection as an array(b) Indexers are also convenient as they can also make use of different types of indexers like int, string etc(c) An indexer allows an object to be indexed such as an array(d) All of the mentionedI had been asked this question in homework.My enquiry is from Introduction of Indexers in portion Indexers and Exception Handling of C#

Answer»

Right choice is (d) All of the mentioned

The best I can explain: Indexers provides a view at large scale to visualize a collection of items as an array. It is really easy to use the object of the class that represents a collection as if it is an array. Hence, INDEXED properties allow us to represent such a view. Indexers can also use different types of indexes like int, string ETC. Use int as an index where SEQUENTIAL ACCESS to a collection is desired. When symbolic access is NEEDED, use string as an index.



Discussion

No Comment Found

Related InterviewSolutions