用兩個數,實現求和、求差求積的功能
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
}