コード例 #1
0
        public static Celsius operator +(Farenheit x, Celsius y)
        {
            Farenheit algo = new Farenheit();

            algo = (Farenheit)y;

            return((Farenheit)x._cantidad + (Farenheit)algo._cantidad);
        }
コード例 #2
0
        public static Celsius operator -(Farenheit x, Kelvin y)
        {
            Farenheit algo = new Farenheit();

            algo = (Farenheit)y;

            return((Farenheit)x._cantidad - (Farenheit)algo._cantidad);
        }
コード例 #3
0
        public static bool operator ==(Farenheit f, Kelvin k)
        {
            Farenheit algo = new Farenheit();

            algo = (Farenheit)k;

            if (f.GetCantidad == algo.GetCantidad)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
コード例 #4
0
        static void Main(string[] args)
        {
            Console.Title = "EJ_21";

            Celsius   a = new Celsius();
            Kelvin    b = new Kelvin();
            Farenheit c = new Farenheit();

            Celsius   d = new Celsius(10);
            Kelvin    e = new Kelvin(20);
            Farenheit f = new Farenheit(100);

            Console.WriteLine(a.GetCantidad + " " + b.GetCantidad + " " + c.GetCantidad + " " + d.GetCantidad + " " + e.GetCantidad + " " + f.GetCantidad);

            a = d + e;

            Console.WriteLine("\n " + a.GetCantidad);

            Console.ReadKey();
        }