代码:
private void btnShowName_Click(object sender, EventArgs e)
        {
            for (int intIndex = 0;intIndex<this.Controls; intIndex++)
            {
                MessageBox.Show("Control #" + intIndex.ToString() +
                    "has the name" + this.Controls[intIndex].Name);
            }
        }为什么有错误呢?
错误提示如下:错误 1 运算符“<”无法应用于“int”和“System.Windows.Forms.Control.ControlCollection”类型的操作数 D:\Documents\Visual Studio 2008\Projects\Picture\Picture\Form1.cs 63 35 Picture

解决方案 »

  1.   

    private void btnShowName_Click(object sender, EventArgs e) 
            { 
                for (int intIndex = 0;intIndex <this.Controls.Count; intIndex++) 
                { 
                    MessageBox.Show("Control #" + intIndex.ToString() + 
                        "has the name" + this.Controls[intIndex].Name); 
                } 
            } 没调试,你试试.如不行抱歉.
      

  2.   

     for (int intIndex = 0;intIndex <this.Controls.Count; intIndex++) 
      

  3.   

    for (int intIndex = 0;intIndex <this.Controls.Count; intIndex++) 
      

  4.   

    你把类型转换为tostring()  式下
      

  5.   

    this.Controls是一个数组
    你在 < 右边应该是这个数组的长度