110,538
社区成员
发帖
与我相关
我的任务
分享
public partial class Form1 : Form
{
double temp = 0;
public Form1()
{
InitializeComponent();
}
private void button1_Click(object sender, EventArgs e)
{
try
{
temp = double.Parse(textBox1.Text);
}
catch
{
MessageBox.Show("无法转换.");
return;
}
MessageBox.Show(temp.ToString());
}
}
double a = Convert.ToDouble(textBox1.Text);
Console.WriteLine(a);
double a = double.Parse( textBox1.Text);
Console.WriteLine(a);
string str="-12.3";
double a = Convert.ToDouble(str);
Console.WriteLine(a);