try
{
int iState = Convert.ToInt32( tbOUser.Rows[i][j].ToString() );
}
catch
{
item.SubItems.Add( "未知状态" );
}
tbOUser的类型为DataTable,如果tbOUser.Rows[i][j]是DBNull的话,系统会消耗大量内存,直到这个函数处理完了以后,系统才会起来,
但如果在前面加个判断的话
if ( DBNull.Value != tbOUser.Rows[i][j] )
{
try
{
int iState = Convert.ToInt32( tbOUser.Rows[i][j].ToString() );
catch
{
item.SubItems.Add( "未知状态" );
}
}
else
{
item.SubItems.Add( "未知状态" );
}
}
系统立马就起来了,Convert.ToInt32和int.Parse在这里是一样的效果
