C# Programming Questions and Answers
Choose the correct statement among the following?
Answer: Option (D)
Choose the keyword which declares the indexer?
The indexer is declared using the name this.
Choose the operator/operators which is/are used to access the [] operator in indexers?
The indexer is implemented through the get and set accessors for the [] operator as:
public double this[int idx] {
get
{
if()
{
}
else
{
return([idx]);
}
}
set
{
array[idx];
}
}
Choose the correct statement among the followings?
Answer: Options (A), (B) and (C)
By definition
For a class student consisting of indexer,which among the following declaration of indexers runs the code successfully ?
student a = new student();
a[1,2] = 20;
Answer: Option (B)
Choose the correct option among the following indexers which correctly allows to index in same way as an array?
Answer: Option (A) and (B)
Which among the following are the advantages of using indexers?
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.
Choose the correct alternative that utilizes the indexed property such that a group named class has indexed property which stores or retrieves value to/from an array of 5 numbers?
Answer: Option (B) and (D)
Choose the correct statement about properties describing the indexers?
Answer: Option (D)