Skip to main content

Which of the following is a correct way to declare an indexer in C#?

Subject

Correct answer position
1
Answer option 1
public int this[int index] { get { return array[index]; } set { array[index] = value; } }
Answer option 2
public int this[int index] = { get { return array[index]; } set { array[index] = value; } }
Answer option 3
public int this[int index] => { get { return array[index]; } set { array[index] = value; } }
English

Which of the following is a correct way to declare a dictionary in C#?

Subject

Correct answer position
1
Answer option 1
Dictionary<int, string> dict = new Dictionary<int, string>();
Answer option 2
Dictionary dict = new Dictionary();
Answer option 3
Dictionary<int, string> dict = new Dictionary();
English