怎么样做才可以不出这个异常,我是菜鸟,帮忙看一下
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;
}
}
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;
}
}
2、给分!看了一半,至少在
//返回二维数组,供曲线图调用
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;
}
中,肯定会出现你说的错误。
出错了
我不知道怎么给分
你想使用二维string数组是不?应该这么做:string[,] str = new string[arraySize, 2];
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));
} 其次,根据你的需要看,你把这个数组搞成string类型数组,简直是自找麻烦。