C#问题,急,在线等。help
很急 展开
static void Main(string[] args)
{
Operation operaion = new Operation();
operaion.Number1 = int.Parse(Console.ReadLine());
operaion.Number2 = int.Parse(Console.ReadLine());
operaion.Operator = Console.ReadLine();
Console.WriteLine("{0}{1}{2}={3}", operaion.Number1, operaion.Operator, operaion.Number2, operaion.Calculation());
}
public class Operation
{
public int Number1 { get; set; }
public int Number2 { get; set; }
public string Operator { get; set; }
public double Calculation()
{
switch (Operator)
{
case "+":
return Number1 + Number2;
case "-":
return Number1 - Number2;
case "*":
return Number1 * Number2;
case "/":
return Number1 / Number2;
}
return 0;
}
}
目前为止,体现面向对象三个基本特性的代码我一个也没看到哦!