fork download
  1. using System;
  2.  
  3. public class ObjClass
  4. {
  5. public int val;
  6. }
  7.  
  8. public struct ObjStruct
  9. {
  10. public int val;
  11. }
  12.  
  13. public class Container
  14. {
  15. public Container()
  16. {
  17. objClass=new ObjClass();
  18. }
  19.  
  20. public ObjClass objClass;
  21. public ObjStruct objStruct;
  22. }
  23.  
  24. public class Test
  25. {
  26. public static void Main()
  27. {
  28. Container containerA = new Container();
  29. containerA.objClass.val = 3;
  30. containerA.objStruct.val = 3;
  31.  
  32. ObjClass objClassB = new ObjClass();
  33. objClassB.val = 5;
  34.  
  35. ObjStruct objStructC;
  36. objStructC.val = 5;
  37.  
  38. Console.WriteLine("Step 1");
  39. Console.WriteLine("containerA.objClass.val = " + containerA.objClass.val);
  40. Console.WriteLine("containerA.objStruct.val = " + containerA.objStruct.val);
  41. Console.WriteLine("objClassB.val = " + objClassB.val);
  42. Console.WriteLine("objStructC.val = " + objStructC.val);
  43. Console.WriteLine("");
  44.  
  45. containerA.objClass = objClassB;
  46. containerA.objStruct = objStructC;
  47.  
  48. Console.WriteLine("Step 2");
  49. Console.WriteLine("containerA.objClass.val = " + containerA.objClass.val);
  50. Console.WriteLine("containerA.objStruct.val = " + containerA.objStruct.val);
  51. Console.WriteLine("objClassB.val = " + objClassB.val);
  52. Console.WriteLine("objStructC.val = " + objStructC.val);
  53. Console.WriteLine("");
  54.  
  55. objClassB.val = 7;
  56. objStructC.val = 7;
  57.  
  58. Console.WriteLine("Step 3");
  59. Console.WriteLine("containerA.objClass.val = " + containerA.objClass.val);
  60. Console.WriteLine("containerA.objStruct.val = " + containerA.objStruct.val);
  61. Console.WriteLine("objClassB.val = " + objClassB.val);
  62. Console.WriteLine("objStructC.val = " + objStructC.val);
  63. Console.WriteLine("");
  64. }
  65. }
Success #stdin #stdout 0.03s 33904KB
stdin
Standard input is empty
stdout
Step 1
containerA.objClass.val = 3
containerA.objStruct.val = 3
objClassB.val = 5
objStructC.val = 5

Step 2
containerA.objClass.val = 5
containerA.objStruct.val = 5
objClassB.val = 5
objStructC.val = 5

Step 3
containerA.objClass.val = 7
containerA.objStruct.val = 5
objClassB.val = 7
objStructC.val = 7