拖一个textBox、一个button在窗体上,双击button,在里面写
try
{
double number=Convert.ToDouble(textBox1.Text.Trim());
if(number>0)
{
MessageBox.Show("{0}是正数",number);
}
else if(number==0)
{
MessageBox.Show("{0}是零",number);
}
else
{
MessageBox.Show("{0}是负数",number);
}
}
catch
{
MessageBox.Show("{请输入一个实数");
}