Guest User

Untitled

a guest
Sep 21st, 2018
83
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.71 KB | None | 0 0
  1. class SomeRef { public Int32 x; }
  2.  
  3. struct SomeVal { public Int32 x; }
  4.  
  5. class Program
  6. {
  7. static void Main(string[] args)
  8. {
  9. ValueTypeDemo();
  10. Console.ReadKey();
  11. }
  12.  
  13. static void ValueTypeDemo()
  14. {
  15. SomeRef r1 = new SomeRef();
  16. SomeVal v1 = new SomeVal();
  17. r1.x = 5;
  18. v1.x = 5;
  19. Console.WriteLine(r1.x);
  20. Console.WriteLine(v1.x);
  21.  
  22. SomeRef r2 = r1;
  23. SomeVal v2 = v1;
  24. r1.x = 8;
  25. v1.x = 9;
  26. Console.WriteLine(r1.x);
  27. Console.WriteLine(r2.x);
  28. Console.WriteLine(v1.x);
  29. Console.WriteLine(v2.x);
  30. }
  31. }
Add Comment
Please, Sign In to add comment