fork download
  1. using System;
  2.  
  3. public class Test
  4. {
  5. struct Foo {
  6. public int A {get;set;}
  7. public void SetA(int a) {
  8. A = a;
  9. }
  10. }
  11.  
  12. class Bar {
  13. Foo f;
  14. public Foo F {get{return f;} set {f = value;}}
  15. public void SetFooA(int x) {
  16. f.SetA(x);
  17. }
  18. }
  19.  
  20. public static void Main()
  21. {
  22. Bar b = new Bar();
  23. b.F.SetA(123);
  24. Console.WriteLine("{0}", b.F.A);
  25. b.SetFooA(456);
  26. Console.WriteLine("{0}", b.F.A);
  27. b.F = new Foo { A = 112233 };
  28. Console.WriteLine("{0}", b.F.A);
  29. }
  30. }
Success #stdin #stdout 0.01s 131648KB
stdin
Standard input is empty
stdout
0
456
112233