• operator


    /*
     * 由SharpDevelop创建。
     * 用户: jinweijie
     * 日期: 2015/10/28
     * 时间: 9:15
     * 
     * 要改变这种模板请点击 工具|选项|代码编写|编辑标准头文件
     */
    using System;

    namespace Study
    {
        class Fraction
        {
            int first;
            int second;
            public Fraction()
            {
            }
            public Fraction(int first,int second)
            {
                this.first = first;
                this.second = second;
            }
            public static Fraction operator +(Fraction lhs,Fraction rhs)
            {
                Fraction f = new Fraction();
                f.first = lhs.first + rhs.first;
                f.second = lhs.second + rhs.second;
                return f;
            }
            public void Display()
            {
                Console.WriteLine("first={0}  second={1}",first,second);
            }
        }
        class Program
        {
            public static void Main(string[] args)
            {
                Console.WriteLine("Hello World!");
                
                // TODO: Implement Functionality Here
                Fraction  f1 = new Fraction(1,2);
                Fraction f2 = new Fraction(3,4);
                Fraction f3 = f1 + f2;
                f3.Display();
                
                
                Console.Write("Press any key to continue . . . ");
                Console.ReadKey(true);
            }
        }
    }

  • 相关阅读:
    POI简单初识 Demo (资源来自网络本人属于收藏总结)
    spring学习笔记(6)装配Bean 的种类和区别 【资源来自网络 版权非本人】
    springboot相关
    前沿技术Hyperledger
    MAC版的IDEA快捷键
    JSONObject put,accumulate,element的区别
    1027
    position窗口居中
    http 请求详解大全
    关于Spring注解
  • 原文地址:https://www.cnblogs.com/jinweijie0527/p/4916450.html
Copyright © 2020-2023  润新知