You are reviewing a C# program. The program contains the following class:
The program executes the following code as part of the Main method:
What will be the output when this code is executed?
A. 10
B. 20
C. 30
D. 40
You are reviewing a C# program. The program contains the following class:
The program executes the following code as part of the Main method:
What will be the output when this code is executed?
A. 10
B. 20
C. 30
D. 40
Answer : 30
using System;
class MainClass {
public static void Main (string[] args) {
Rectangle r1, r2;
r1 = new Rectangle{length=10, width=20};
r2 = r1;
r2.length = 30;
Console.WriteLine (r1.length);
}
}
class Rectangle {
public double length{get; set;}
public double width{get; set;}
}