RMarK0

Untitled

Jun 1st, 2020
195
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.87 KB | None | 0 0
  1. using System;
  2.  
  3. namespace ConsoleApp1
  4. {
  5.     class Result
  6.     {
  7.         public int Value { get; set; }
  8.  
  9.         public static Result operator +(Result c1, Result c2)
  10.         {
  11.             return new Result { Value = c1.Value + c2.Value };
  12.         }
  13.         public static bool operator >(Result c1, Result c2)
  14.         {
  15.             return c1.Value > c2.Value;
  16.         }
  17.         public static bool operator <(Result c1, Result c2)
  18.         {
  19.             return c1.Value < c2.Value;
  20.         }
  21.  
  22.     }
  23.     class Program
  24.     {
  25.         static void Main(string[] args)
  26.         {
  27.             short a = 10;
  28.             int b = 25;
  29.  
  30.             Result res1 = new Result{Value = (int)a };
  31.             Result res2 = new Result { Value = b };
  32.  
  33.             Result total = res1 + res2;
  34.             Console.WriteLine(total.Value);
  35.             Console.Read();
  36.         }
  37.     }
  38. }
Add Comment
Please, Sign In to add comment