

MCQOPTIONS
Saved Bookmarks
1. |
If a class Student has an indexer, then which of the following is the correct way to declare this indexer to make the C#.NET code snippet given below work successfully? Student s = new Student(); s[1, 2] = 35; |
A. | <pre><code class="csharp">class Student { int[ ] a = new int[5, 5]; public property WriteOnly int this[int i, int j] { set { a[i, j] = value; } } }</code></pre> |
B. | <pre><code class="csharp">class Student { int[ , ] a = new int[5, 5]; public int property WriteOnly { set { a[i, j] = value; } } }</code></pre> |
C. | <pre><code class="csharp">class Student { int[ , ] a = new int[5, 5]; public int this[int i, int j] { set { a[i, j] = value; } } }</code></pre> |
D. | <pre><code class="csharp">class Student { int[ , ] a = new int[5, 5]; int i, j; public int this { set { a[i, j] = value; } } }</code></pre> |
Answer» D. <pre><code class="csharp">class Student { int[ , ] a = new int[5, 5]; int i, j; public int this { set { a[i, j] = value; } } }</code></pre> | |