Guest User

Untitled

a guest
Feb 17th, 2019
101
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.72 KB | None | 0 0
  1. using System;
  2.  
  3. namespace ConsoleApp1
  4. {
  5. struct Mutable
  6. {
  7. public Mutable(int x, int y)
  8. : this()
  9. {
  10. X = x;
  11. Y = y;
  12. }
  13. public void IncrementX() { X++; }
  14. public int X { get; private set; }
  15. public int Y { get; set; }
  16. }
  17. class A
  18. {
  19. public A() { Mutable = new Mutable(x: 5, y: 5); }
  20. public Mutable Mutable { get; private set; }
  21. }
  22.  
  23.  
  24. internal class Program
  25. {
  26. private static void Main(string[] args)
  27. {
  28. A a = new A();
  29.  
  30. Console.WriteLine(a.Mutable.X);
  31.  
  32. a.Mutable.IncrementX();
  33.  
  34. Console.WriteLine(a.Mutable.X);
  35.  
  36. Console.ReadKey();
  37. }
  38. }
  39. }
Add Comment
Please, Sign In to add comment