

MCQOPTIONS
Saved Bookmarks
1. |
Which of the following is the correct way to implement a read only property Length in a Sample class? |
A. | <pre><code class="csharp">class Sample { int len; public int Length { get { return len; } } }</code></pre> |
B. | <pre><code class="csharp">class Sample { public int Length { get { return Length; } } }</code></pre> |
C. | <pre><code class="csharp">class Sample { int len; public int Length { get { return len; } set { len = value; } } }</code></pre> |
D. | <pre><code class="csharp">class Sample { int len; public int Length { Readonly get { return len; } } }</code></pre> |
Answer» B. <pre><code class="csharp">class Sample { public int Length { get { return Length; } } }</code></pre> | |