using System;
using System.Collections.Generic;
using System.Text;
namespace TestC
{
class number
{
public static void Main()
{
int n;
System.Console.WriteLine("输入一个整数");
System.Console.WriteLine("输入字母则跳出");
string str = System.Console.ReadLine();
number num = new number();
while (num.IsNumber(str))
{
n = Convert.ToInt32(str,10);
if (n % 2 == 0)
Console.WriteLine("这个数为偶");
else
Console.WriteLine("这个数为奇");
str = System.Console.ReadLine();
}
Console.ReadLine();
}
private bool IsNumber(string number)
{
try
{
for (int i = 0; i < number.Length; i++)
{
if (!char.IsNumber(number, i))
{
return false;
}
}
return true;
}
catch
{
return false;
}
}
}
}