Hello to all of you. I have been reading through a lot of the posts in the forums and have noticed that there are a lot of people willing to help out others and give advice. Well I am new to programming and am trying to learn how to code in C#. My issue is that I am trying to write a program in C# using the windows form style, (not as a console application), that allows a user to enter a string value in 5 separate text boxes. Upon clicking a button, the program should display the values entered into two separate labels,each on a new line. One label will list them in the order in which they were input, and another that lists them in the reverse order. The catch is we have to store the users values in an array, and then use a foreach loop for one of the labels, and a regular for loop for the other label. I am having trouble figuring out how to store a value from a textbox into the array, and then have the program display those values into the appropriate labels. Any help that is offered would be greatly appreciated. Thank you in advance.

Well you could create something like this:

string [] stringArray = new string;
stringArray[] = textBox1, textBox2, ... , textBox5

then you could create another one with a different name.

the for loop you could do:

string anyname = ""
for (int i = 0; i <whatever; i ++)
     // this is the spot you put the code
     // anyname += whatever you put up + "\n"
label1.text = "Ordered  Strings\n" + anyname;
This article has been dead for over six months. Start a new discussion instead.