for (int i = 0,j=1; i < 12 && j<13; i++,j++)
{
dr = dt.NewRow();
if (ds.Tables[0].Rows.Count != 0)
{
if (ds.Tables[0].Rows[i]) 当这个I 的值 超过了下标的有效范围 该如何判断?? Rows的下标只有 0和1
{}
else
{}
{
dr = dt.NewRow();
if (ds.Tables[0].Rows.Count != 0)
{
if (ds.Tables[0].Rows[i]) 当这个I 的值 超过了下标的有效范围 该如何判断?? Rows的下标只有 0和1
{}
else
{}
if (ds.Tables[0].Rows.Count != 0 && ds.Tables[0].Rows.Count >i) ortry
{
.....
}
catch(indexoutofrangeexception)
{
.......
}
第一次看到这种循环,能不能解释一下!
这个可以,就判断下标大于i值吧你的这种循环我建议使用,是二重吗,还是什么意思呢,i<12的同时要j<13,不好控制吧
i 表示下标 j表示月份 请指教
{
dr = dt.NewRow();
if (ds.Tables[0].Rows.Count != 0)
{
if(i<2 && ds.Tables[0].Rows[i])
{}
else
{}
}
想问下,如果Rows的下标只有 0和1,为什么还要用i来控制呢?
{
dr = dt.NewRow();
if (ds.Tables[0].Rows.Count > i)
{
if (ds.Tables[0].Rows[i])
{}
else
{}
for (int i = 0,j=1; i < 12 && j <13; i++,j++)
{
dr = dt.NewRow();
rs = ds.Tables[0].Rows.Count ;
if (rs != 0)
{
if(i<= rs)
{
if (ds.Tables[0].Rows[i]) 当这个I 的值 超过了下标的有效范围 该如何判断?? Rows的下标只有 0和1
{}
else
{}
}
}这样就可以了,也可以用break之类的吧。