我有一个数据行,其中一列中有一个整数。但是,以下代码不会评估为 true。我很难理解为什么。我错过了什么?
foreach (DataRow dr in dataset.Tables[0].Rows)
{
//this evaluates as false, even when I have a valid castable INT value in the column (as an object).
if (dr[3] is int)
{
if (Convert.ToInt32(dr[3]) == 3)
{
//do something with row
}
else if (Convert.ToInt32(dr[3]) == 4)
{
//do someting else with row
}
}
}