1、用户输入 *.exe x + y(x和y是整数,输出 x + y的结果)。
2、用户输入 *.exe x – y(x和y是整数,输出 x - y的结果)。
3、用户输入 *.exe x / y(x和y是整数,输出 x / y的结果)。
4、用户输入 *.exe x * y(x和y是整数,输出 x * y的结果)。
5、用户输入 *.exe –h则显示帮助。
class Program
{
static void Main(string[] args)
{
string a = args[0];
try
{
if (a == "-h")
{
Console.WriteLine("This is Help Document !");
}
else
{
string b = args[1];
string c = args[2];
int ai = int.Parse(a);
int ci = int.Parse(c);
if (b == "+")
{
Console.WriteLine("{0} + {1} = {2}", ai, ci, ai + ci);
}
else if (b == "-")
{
Console.WriteLine("{0} - {1} = {2}", ai, ci, ai - ci);
}
else if (b == "*")
{
Console.WriteLine("{0} * {1} = {2}", ai, ci, ai * ci);
}
else if (b == "/")
{
Console.WriteLine("{0} / {1} = {2}", ai, ci, ai / ci);
}
else
{
Console.WriteLine("Invaliable b!");
}
}
}
catch (Exception)
{
Console.WriteLine("Invaliable a !");
}
Console.ReadKey();
}
}