for (int i = 1; i <= 10; i++)
       {
            TextBox L = this.Controls["TextBox" + i] as TextBox;
            Label T = this.Controls["Labell" + i] as Label;       }
如何比较L.Text == T.text 和L.Text != T.Text。另外:有两个计数的Textbox11 (记录正确的数量)和Textbox12(记录错误的数量),当L.Text == T.text时Textbox11.Text记录正确的数量,当L.Text != T.Text时Textbox12.Text记录错误的数量.

解决方案 »

  1.   

    if(T!=null&&L!=null)
    {
     if(L.Text.Equals(T.Text)){}
     else{}
    }
      

  2.   


    int m=0;
    int n=0;
    for (int i = 1; i <= 10; i++)
      {
      TextBox L = this.Controls["TextBox" + i] as TextBox;
      Label T = this.Controls["Labell" + i] as Label;
       if(L.Text == T.Text) 
       {
         m++;
       }
        else
       {
          n++;
       } 
      }
    Textbox11.Text=m.ToString();
    Textbox12.Text=n.ToString();
      

  3.   

    wuyq11能给我你的QQ吗?那样还方便问您问题,您这样写我不是很明白!!
      

  4.   

    这样不能解决,这样的话Textbox11.Text=m.ToString();
    Textbox12.Text=n.ToString();显示的数量是错误的
      

  5.   


    int m=0;
    int n=0;
    for (int i = 1; i <= 10; i++)
      {
      TextBox L = this.Controls["TextBox" + i] as TextBox;
      Label T = this.Controls["Labell" + i] as Label;
      if(T!=null&&L!=null)
    {
       if(L.Text == T.Text) 
       {
         m++;
       }
        else
       {
          n++;
       } 
    }
      }
    Textbox11.Text=m.ToString();
    Textbox12.Text=n.ToString();
      

  6.   

    like this : textBox11.Text = "0";
                textBox12.Text ="0";
                for (int i = 1; i <= 10; i++)
                {
                    TextBox L = this.Controls["TextBox" + i] as TextBox;
                    Label T = this.Controls["Labell" + i] as Label;
                    if (L!=null && T!=null)
                    {
                        if (L.Text.Equals(T.Text))
                        {
                            textBox11.Text = textBox11.Text + 1;
                        }
                        else
                        {
                            textBox12.Text = textBox12.Text + 1;
                        }
                    }
                }