private short m_RuntimeRows;
short theInt16_1;for (theInt16_1 = 0; (theInt16_1 < this.m_RuntimeRows); theInt16_1 = ((short) (theInt16_1 + 1)))
{}
上面这段代码,我知道是个循环,但是看不懂是什么意思。谁能帮我解释一下吗?
short theInt16_1;for (theInt16_1 = 0; (theInt16_1 < this.m_RuntimeRows); theInt16_1 = ((short) (theInt16_1 + 1)))
{}
上面这段代码,我知道是个循环,但是看不懂是什么意思。谁能帮我解释一下吗?
short theInt16_1;
for (theInt16_1 = 0; theInt16_1 < m_RuntimeRows; theInt16_1++)
{} 和这个写法完全一样的效果。
theInt16_1 = theInt16_1 + 1;因为short和int相加,结果会隐试转换为int,所以前面要加一个类型转换。
theInt16_1 = 0 设置初始值
(theInt16_1 < this.m_RuntimeRows) 边界条件,括号可以不写,估计作者怕影响后面代码
theInt16_1 = ((short) (theInt16_1 + 1)) 让theInt16_1 加1,强制转换为sort,防止类型自动被转换为int,
for (循环开始之前执行; 判断循环是否应该继续的条件表达式; 在每次循环结束之后执行)
for (循环开始之前执行; 判断循环是否应该继续的条件表达式; 在每次循环结束之后执行)
{
循环体
}
循环开始之前执行
while (判断循环是否应该继续的条件表达式)
{
循环体
在每次循环结束之后执行
}
循环开始之前执行
label_loopstart:
if (判断循环是否应该继续的条件表达式)
{
循环体
在每次循环结束之后执行
}
else
{
goto label_loopend:
}
goto label_loopstart:
label_loopend:
theInt16_1 =0
theInt16_1 < this.m_RuntimeRows加上这个条件,循环根本不会执行,毫无意义,也不会浪费时间。
private short m_RuntimeRows;
private void GeneralDraw ()
{
int theInt32_2;
short theInt16_3;
short theInt16_2;
short theInt16_1; string theString1;
int theInt32_1;
if (! this.m_FirstDraw)
{
this.g.FillRectangle (this.m_BackBrush, ((int) this.m_LeftPixels), ((int) this.m_TopPixels), ((int) this.m_WidthPixels), ((int) this.m_HeightPixels));
}
if ((this.m_Orientation == enumOrientation.or0) || (this.m_Orientation == enumOrientation.or180))
{
this.m_CurrX = this.m_LeftMargainPixels;
this.m_CurrY = this.m_TopMargainPixels;
}
else
{
this.m_CurrX = this.m_TopMargainPixels;
this.m_CurrY = this.m_LeftMargainPixels;
}
if (this.m_FirstDraw)
{
this.BinaryCompact ();
}
theInt32_1 = 0;
theString1 = null;
for (theInt16_1 = 0; (theInt16_1 < this.m_RuntimeRows); theInt16_1 = ((short) (theInt16_1 + 1)))
{
if ((this.m_Orientation == enumOrientation.or0) || (this.m_Orientation == enumOrientation.or180))
{
this.m_CurrX = this.m_LeftMargainPixels;
}
else
{
this.m_CurrX = this.m_TopMargainPixels;
}
theInt16_2 = ((short) (theInt16_1 * this.m_ModuleHeightPixels));
theInt16_3 = ((short) (- (((this.m_RuntimeRows - theInt16_1) - 1) * this.m_ModuleHeightPixels)));
theString1 = this.GetPattern (130728);
this.DrawChar ("bwbwbwbw", theString1, theInt16_2, theInt16_3);
theString1 = this.GetPattern (BarcodePDF417.PDF417_BITS[(theInt16_1 % 3), ((int) this.GetRowStart (theInt16_1))]);
this.DrawChar ("bwbwbwbw", theString1, theInt16_2, theInt16_3);
for (theInt32_2 = 0; (theInt32_2 < this.m_Columns); theInt32_2 += 1)
{
theString1 = this.GetPattern(BarcodePDF417.PDF417_BITS[(theInt16_1 % 3), ((int)this.m_EncodedData[theInt32_1++])]); //此处提示“索引超出了数组界限”,所以是运行到了这里。
this.DrawChar("bwbwbwbw", theString1, theInt16_2, theInt16_3);
}
if (! this.m_TruncatedSymbol)
{
theString1 = this.GetPattern (BarcodePDF417.PDF417_BITS[(theInt16_1 % 3), ((int) this.GetRowEnd (theInt16_1))]); this.DrawChar ("bwbwbwbw", theString1, theInt16_2, theInt16_3);
this.DrawChar ("bwbwbwbwb", "711311121", theInt16_2, theInt16_3);
}
else
{
this.DrawChar ("bw", "11", theInt16_2, theInt16_3);
}
this.m_CurrY = ((short) (this.m_CurrY + this.m_ModuleHeightPixels));
}
}