c# 控制台应用程序,输入两个数,并判断输入的内容是否是数值型

如题所述

String Input=Console.ReadLine();
int i=0;
bool isInt=int.TryParse(Input,out i);
if (isInt)
{
Console.WriteLine("{0}是数值型",i);
}
else
{
Console.WriteLine("{0}不是是数值型",i);
}

这是判断一个数的 你可以根据这个程序自己添加另一个数
温馨提示:内容为网友见解,仅供参考
第1个回答  2011-05-11
string a=Console.In.ReadLine();
int b = 0;
if (Int32.TryParse(a, out b))
Console.Out.WriteLine("是" + b);
else
Console.Out.WriteLine("不是" + b);
第2个回答  2011-05-12
string str = "14414131321151121";
int i = new int();
i = System.Int32.Parse(str.Substring(6, 1));
Console.Write(i.ToString()+" 是 :");

if ((i % 2).Equals(0))
{
Console.Write("偶数");
}
else
{
Console.Write("奇数");
}

System.Console.ReadLine();
相似回答
大家正在搜