1.

Which of the following is the correct way to implement a read only property Length in a Sample class?

A. class Sample { int len; public int Length { get { return len; } } }
B. class Sample { public int Length { get { return Length; } } }
C. class Sample { int len; public int Length { get { return len; } set { len = value; } } }
D. class Sample { int len; public int Length { Readonly get { return len; } } }
Answer» B. class Sample { public int Length { get { return Length; } } }


Discussion

No Comment Found

Related MCQs