Guest User

Untitled

a guest
Sep 27th, 2020
19
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.70 KB | None | 0 0
  1. using System;
  2.  
  3. namespace TestsDecimals
  4. {
  5. public static class Program
  6. {
  7. public static void Main(string[] args)
  8. {
  9. var a = new A();
  10. a.SetA(5);
  11. a.SetB(6);
  12. Console.WriteLine(a.GetA); // 5
  13. Console.WriteLine(a.GetB); // 6
  14. Console.WriteLine(a.C); // 5 * 6 = 30
  15. }
  16. }
  17.  
  18. public class A
  19. {
  20. private int _a;
  21. private int _b;
  22.  
  23. // setters
  24. public void SetA(int a) => _a = a;
  25. public void SetB(int b) => _b = b;
  26.  
  27. // getters
  28. public int GetA => _a;
  29. public int GetB => _b;
  30.  
  31. public int C => _a * _b;
  32. }
  33. }
Advertisement
Add Comment
Please, Sign In to add comment