索引和长度必须引用该字符串内的位置。
问题描述:
索引和长度必须引用该字符串内的位置。
参数名: length
行161: public string GetReaderID(){
行162: DataSet ds = GetAllReader("tb_reader");
行163: string strReaderID = "";
行164: if (ds.Tables[0].Rows.Count == 0)
行165: strReaderID = "DZ10001";
行166: else
行167: strReaderID = "DZ" + (Convert.ToInt32(ds.Tables[0].Rows[ds.Tables[0].Rows.Count - 1][0].ToString().Substring(2, 5)) + 1);
行168: return strReaderID; }
想请问一下这里错哪里了?怎么改?谢谢!
答
字符串长度不够7个字符,这里截取出错了。题主最好检查下数据内容
ds.Tables[0].Rows[ds.Tables[0].Rows.Count - 1][0].ToString().Substring(2, 5)
答
Substring(2, 5)出错了