通过silverlight做的一个解二元一次方程的程序运行出错,但是在C#下运行良好,什么问题

kila1002 2012-04-17 02:34:23
using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;

namespace 一元二次方程
{
public partial class MainPage : UserControl
{
public MainPage()
{
InitializeComponent();
}

private void button1_Click(object sender, RoutedEventArgs e)
{
String a;
String b;
String c;
double x1;
double x2;
a = Console.ReadLine();
b = Console.ReadLine();
c = Console.ReadLine();
double a1 = double.Parse(a);
double b1 = double.Parse(b);
double c1 = double.Parse(c);

if (b1 * b1 - 4 * a1 * c1 > 0)
{
x1 = (-b1 - Math.Sqrt(b1 * b1 - 4 * a1 * c1)) / (2 * a1);
x2 = (-b1 + Math.Sqrt(b1 * b1 - 4 * a1 * c1)) / (2 * a1);
Console.WriteLine("x1与X2分别等于:" + x1 + x2);
}


else if (b1 * b1 - 4 * a1 * c1 < 0)
{
Console.WriteLine("错误,无解");
}
else
{
x1 = x2 = -b1 / (2 * a1);
Console.WriteLine("两根相等,x1=x2=" + x1);
}
}
}
}

按F5之后,输入abc所对应的三个数字,就会跳出告诉我

用户代码未处理 ArgumentNullException
值不能为 null。
参数名: value

请问这个是什么原因,这段代码在C#中运行没有任何问题

求告知!!!十分感谢
...全文
66 1 打赏 收藏 转发到动态 举报
写回复
用AI写文章
1 条回复
切换为时间正序
请发表友善的回复…
发表回复
kila1002 2012-04-17
  • 打赏
  • 举报
回复
顶起来,我好像知道答案啊

111,126

社区成员

发帖
与我相关
我的任务
社区描述
.NET技术 C#
社区管理员
  • C#
  • Creator Browser
  • by_封爱
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

让您成为最强悍的C#开发者

试试用AI创作助手写篇文章吧