用两个数,实现求和、求差求积的功能

 using System;
using System.Collections.Generic;
using System.Text;

namespace BBSCTIANHUI.OOPStudy.ConsoleStruct
{
    class Program
    {
      #region
        static void Main(string[] args)
        {
            MathStruct mathStruct = new MathStruct();
            mathStruct.operandFirst = 10;
            mathStruct.operandSecond = 12;

            Console.WriteLine(mathStruct.GetAddValue());
            Console.WriteLine(mathStruct.GetMinusValue());
            Console.WriteLine(mathStruct.GetMulitipValue());
            Console.ReadLine();
        }
#endregion
    }

    #region write method to struct
    public struct MathStruct
    {
        public int operandFirst;
        public int operandSecond;
       
        /// <summary>
        ///
        /// </summary>
        /// <returns>求和</returns>
        public int GetAddValue()
        {
            return (operandFirst + operandSecond);
        }

        /// <summary>
        /// substration method
        /// </summary>
        /// <returns>substration value</returns>
        public int GetMinusValue()
        {
            return (operandFirst - operandSecond);
        }

        /// <summary>
        /// Mulitip method
        /// </summary>
        /// <returns>Mulitip value</returns>
        public int GetMulitipValue()
        {
            return (operandFirst * operandSecond);
        }
    }
    #endregion
}

posted on 2008-09-19 13:31  Ready  阅读(1001)  评论(1)    收藏  举报