Advertisement
Guest User

Untitled

a guest
Oct 21st, 2019
85
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.60 KB | None | 0 0
  1. using System;
  2.  
  3. namespace RTFM
  4. {
  5. class Program
  6. {
  7. private struct Mutable
  8. {
  9. private int x;
  10. public int Mutate()
  11. {
  12. x++;
  13. return x;
  14. }
  15. }
  16.  
  17. readonly Mutable m = new Mutable();
  18.  
  19. public Program()
  20. {
  21. Console.WriteLine("-= Mutating from constructor =-");
  22. Console.WriteLine(m.Mutate());
  23. Console.WriteLine(m.Mutate());
  24. Console.WriteLine(m.Mutate());
  25. }
  26.  
  27. static void Main(string[] args)
  28. {
  29. Program t = new Program();
  30. Console.WriteLine("-= Mutating from Main =-");
  31. Console.WriteLine(t.m.Mutate());
  32. Console.WriteLine(t.m.Mutate());
  33. Console.WriteLine(t.m.Mutate());
  34. }
  35. }
  36. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement