“MutableProperty” (Problem)
What will the following code display?
1
public struct Foo
2
{
3
public int Value;
4
public void Change(int newValue)
5
{
6
Value = newValue;
7
}
8
}
9
public class Bar
10
{
11
public Foo Foo { get; set; }
12
}
13
void Main()
14
{
15
var bar = new Bar { Foo = new Foo() };
16
bar.Foo.Change(5);
17
Console.WriteLine(bar.Foo.Value);
18
}
Copied!
Solution
Copy link