【发布时间】:2015-11-28 10:02:16
【问题描述】:
当我尝试访问数据集表的一行中的值时,出现索引超出数组错误。这是代码
DataRow[] userRow = newsdataset.Tables["users"].Select("Id = " + userid);
if (userRow != null && userRow.Length != 0)
{
string connectionName = userRow[1].ToString() + " " + userRow[2].ToString();
}
当我调试时,我可以看到 userRow 不是 null 并且它在数组中有值。
编辑 - 我应该添加 - 我没有混淆索引(我知道索引从 0 开始)当我尝试检索索引 1 和 2 时出现错误,但在调试中我可以看到该行数组在索引 0、1、2 和 3 处具有值
有什么线索吗? 谢谢!
【问题讨论】:
标签: c# asp.net dataset indexoutofboundsexception