异常详细信息: 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;
}
}
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;
}
}
...全文
相关推荐
VS2005(c#)项目调试问题解决方案集锦(三)
问题19:“System.NullReferenceException: 未将对象引用设置到对象的实例”。这是一个非常常见的错误,表示尝试访问一个null对象。
VS2005(c#)项目调试疑难问题解决方法锦集
System.NullReferenceException: 未获取实例**问题描述**:当尝试访问未初始化的对象实例时,会抛出此异常。
未将对象引用设置到对象的实例 (System.NullReferenceException)
【未将对象引用设置到对象的实例 (System.NullReferenceException)】是.NET开发中常见的运行时错误,这个异常表示尝试访问或操作一个尚未初始化的对象,即该对象的引用是`null
Windbg+Net调式案例—实验2 崩溃
- **异常类型**:System.NullReferenceException - **消息**:对象引用未设置为对象的实例。
System.NullReferenceException(解决方案).md
在编程过程中,尤其是使用面向对象的语言如C#进行项目开发时,我们经常会遇到一个常见的异常问题:System.NullReferenceException,也就是空引用异常。


