Question: C# Determine the output produced by the following C# code that uses struct and class definitions: public struct S { public int v; public S(int
C#
Determine the output produced by the following C# code that uses struct and class definitions:
public struct S {
public int v;
public S(int a)
{ v = a; }
}
public class C {
public int v;
public C(int a)
{ v = a; }
}
S s1 = new S(1);
S s2 = new S(2);
Console.WriteLine("{0} {1}", s1.v, s2.v);
s2 = s1;
s1.v = 3;
Console.WriteLine("{0} {1}", s1.v, s2.v);
C c1 = new C(1);
C c2 = new C(2);
Console.WriteLine("{0} {1}", c1.v, c2.v);
c2= c1;
c1.v = 3;
Console.WriteLine("{0} {1}", c1.v, c2.v);
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
