Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class Program
- {
- static void Main()
- {
- int[] operatorValues = GetOperatorValues();
- var myClass = new Operator(operatorValues[0], operatorValues[1]);
- var swapResult = myClass.SwapValues();
- Console.WriteLine($"{swapResult.a} {swapResult.b}");
- }
- private static int[] GetOperatorValues()
- {
- int counter = 0;
- bool isNum;
- int[] result = new int[2];
- while (counter < 2)
- {
- var input = Console.ReadLine();
- isNum = int.TryParse(input, out int num);
- if (isNum)
- {
- result[counter++] = num;
- }
- }
- return result;
- }
- public class Operator
- {
- public Operator(int a, int b)
- {
- this.A = a;
- this.B = b;
- }
- public int A { get; private set; }
- public int B { get; private set; }
- public (int a, int b) SwapValues()
- {
- this.B += this.A;
- this.A = this.B - this.A;
- this.B -= this.A;
- return (this.A, this.B);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement