异常详细信息: System.NullReferenceException的问题
怎么样做才可以不出这个异常,我是菜鸟,帮忙看一下
using System;
using System.Data;
using System.Configuration;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Collections;
/// <summary>
/// Util 的摘要说明
/// </summary>
public class Util
{
private static ArrayList valueList = new ArrayList();
private static ArrayList countList = new ArrayList();
public Util()
{
//
// TODO: 在此处添加构造函数逻辑
//
}
//返回二维数组,供曲线图调用
public static string[][] readBgValueArray()
{
int arraySize=bgValueCount();
string[][] str = new string[arraySize][];
for (int i = 0; i < str.Length; i++)
{
str[i][0] = Convert.ToString(Math.Round((double)valueList[i],2));
str[i][1] = Convert.ToString(Math.Round((double)countList[i],2));
}
return str;
}
//计算正数存储大小
public static int bgValueZCount()
{
string value = "";
int j = 0;
int count = 0;
double d = 0.01;
while ( d <= 1)
{
value= Convert.ToString(Math.Round(d,2));
j = DBCommand.readBackGroundValueCount(value);
if (j > 0)
{
valueList.Add(d);
countList.Add(j);
count++;
}
d += 0.01;
}
return count;
}
//计算负数数存储大小
public static int bgValueFCount()
{
string value = "";
int j = 0;
int count = 0;
double d = -0.01;
while (d >= -1)
{
value = Convert.ToString(Math.Round(d, 2));
j = DBCommand.readBackGroundValueCount(value);
if (j > 0)
{
valueList.Add(d);
countList.Add(j);
count++;
}
d += -0.01;
}
return count;
}
//计算NULL存储大小
public static bool bgValueNullCount()
{
bool flag=false;
int count= DBCommand.readBackGroundValueCount("NULL");
if (count > 0)
{
valueList.Add("NULL");
countList.Add(count);
flag = true;
}
return flag;
}
//计算比值个数
public static int bgValueCount()
{
int zCount = bgValueZCount();
int fCount = bgValueFCount();
int nullCount = 0;
if (bgValueNullCount())
{
nullCount = 1;
}
return zCount + fCount + nullCount;
}
}