What Will Be The Output Of The Following C Codep Pre Langcsharp #483

What will be the output of the following C# code?</p> <pre><code class="language-csharp" line="1"> class student { int []scores = new int[3] {13, 32, 24}; public int this[int index] { get { if (index < 3) return scores[index]; else { Console.WriteLine("invalid index"); return 0; } } private set { if (index < 3) scores[index] = value; else Console.WriteLine("invalid index"); } } } class Program { public static void Main(string[] args) { student s = new student(); int[] scores1 = new int[3] {8, 19, 40}; for (int i = 0; i < 3; i++) { if (scores1[i] > s[i]) { Console.WriteLine(" scores1 had greater value :" + scores1[i]); } else { Console.WriteLine("scores had greater value :" + s[i]); } } Console.ReadLine(); } } </code></pre>

Online Quiz This multiple choice question (MCQ) is related to the book/course gs gs108 CSharp. It can also be found in gs gs108 Indexers and Exception Handling - Properties and its Applications - Quiz No.1.


Similar question(s) are as followings:



Online Quizzes of gs108 CSharp

Choose an organization

Theme Customizer

Gaussian Texture



Gradient Background