AmbitionBox
Discover Best Places to work in India
Discover best places to work
Compare & find best workplace
Bring your workplace to life
Highlight your company's perks
Read reviews for 6L+ companies
Rate your former or current company
Discover salaries for 8L+ companies
Calculate your take home salary
Check your market value
Help other jobseekers
Read interviews for 90K+ companies
Interviews questions for 1K+ colleges
Contribute your interview questions
C# Programming
Choose the correct statement among the following?
A property can be a static member whereas an indexer is always an instance member
A get accessor of a property corresponds to a method with no parameters whereas get accessor of an indexer corresponds to a method with the same formal parameters lists as the indexer
It is an error for indexer to declare a local variable with the same name as indexer parameters
All of the mentioned
Answer: Option (D)
Choose the keyword which declares the indexer?
base
this
super
extract
The indexer is declared using the name this.
Choose the operator/operators which is/are used to access the [] operator in indexers?
get
set
access
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?
Indexers are location indicators
Indexers are used to access class objects
Indexer is a form of property and works in the same way as a property
None of the mentioned
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;
class student {int[,] p =newint[6, 6];public property WriteOnly intthis[int i, int j]{set{ a[i, j]=value;}}}
class student {int[,] a =newint[6, 6];publicintthis[int i, int j]{set{ a[i, j]=value;}}}
class student {int[,] a =newint[6, 6];publicint property WriteOnly {set{ a[i, j]=value;}}}
Answer: Option (B)
Choose the correct option among the following indexers which correctly allows to index in same way as an array?
A class
An interface
A function
A property
Answer: Option (A) and (B)
Which among the following are the advantages of using indexers?
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
Indexers are also convenient as they can also make use of different types of indexers like int, string etc
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?
group[3] = 34;
group g = new group(); g[3] = 34;
Console.WriteLine(group[3]);
group g = new group(); Console.WriteLine(g[3]);
Answer: Option (B) and (D)
Choose the correct statement about properties describing the indexers?
No need to use the name of the property while using an indexed property
An indexer property should accept at least one argument
Indexers can be overloaded
Join India’s largest community to research company culture
Are you a student or working professional?
Student/Never worked
I am a student/I have never worked
Working Professional
I am working/I have worked before
What are your preferred job locations?
Popular Cities
Other Cities
Follow your preferred designations/job profiles
Suggestions based on your job profile
vs
Similar Companies