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记录错误的数量.
{
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记录错误的数量.
{
if(L.Text.Equals(T.Text)){}
else{}
}
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();
Textbox12.Text=n.ToString();显示的数量是错误的
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();
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;
}
}
}