Which of the following statements is/are in-correct related to declaring a reference type as read only variable for the following code ?
public class A
public readonly B b = new B();
public class B
public int x = 10;
public class Test
public static void Main(string args)
A t = new A();//Line 1
t.b = new B();//Line2
t.b.x = 30;//Line3
All 3 lines of code will fail during compilation.
Only Line2 and Line3 will fail during compilation.
Only Line2 will produce a compilation error.
Only Line3 will produce a compilation error.
It is allowed to change variable x data since the variable is not a constant or read-only. But variable b is declared as read only and hence we cannot store new objects address into it .
Back To Top