6
Reply

Instructions with a counter

Serban Gabriel

Serban Gabriel

Mar 1 2011 8:21 PM
1.5k
I am sorry for the confusing subject name. 
I am newbie to C# programming so i need a little help. Sorry for my english.

Introduction:
I have 6 columnHeader named columnHeader_p1s, p2s, p3s, p4s, p5s, p6s.
All the above columnHeaders are initiated with the .Text = "default")

I have 4 textBox named textBox_p1, p2, p3, p4.
(textBox_p1.Text = "player 1"
textBox_p2.Text = "player2")
textBox_p3.Text = "player3")
textBox_p4.Text = "player4")

The problem:
n = 4;
for ( i = 1; i <= n; i++ )
{
 this.columnHeader_p{i}s.Text = textBox_p{i}.Text;
}

I want to achieve the result with a similar command to the above one. (i know the above one is not correct)
I hope you understand what i want :D.

Is it possible?

The result:
columnHeader_p1s.Text = player1;
columnHeader_p2s.Text = player2;
columnHeader_p3s.Text = player3;
columnHeader_p4s.Text = player4;
columnHeader_p5s.Text = default;
columnHeader_p6s.Text = default;

"Case" is out of discussion.

Answers (6)