请教一个问题,我遍历Form1的所有控件写了两种写法,
1  foreach (Control c in thiPg.FindControl("Form1").Controls)
            {
                if (c.GetType() == new TextBox().GetType())
                {
                    TextBox txt = (TextBox)c;
                   
                        if (showNow)
                        {
                            txt.Text = (prs[x].GetValue(myClass, null)).ToString();  //给txt赋值
                            x++;
                        }
                        else
                        {
                            txt.Visible = false;
                        }                               }通过2
int x = 0;
if (obj.GetType() == new TextBox().GetType())
            {
                x = 1;                foreach (Control c in thiPg.FindControl("Form1").Controls)
                {
                    if (yes)
                    {
                        if (c.GetType() == new Label().GetType())
                        {
                            TextBox txt = (TextBox)c;
                           
                                txt.Visible = true;
                                txt.Text = txtString;
                                x++;
                            
                        }
                    }
失败请问这个为什么失败,要如何去改尼。