Correct Answer: class Student { int[] scores = new int[5] {3, 2, 4, 1, 5}; public int this[ int index ] { get { if (index < 5) return scores[ index ]; else { Console.WriteLine("Invalid Index"); return 0; } } set { if (index < 5) scores[ index ] = value; else Console.WriteLine("Invalid Index"); } } }
Discussion & Comments